关于网易企业邮箱发邮件的问题connection closed gracefully

lcjmy 2011-03-19 02:54:14
还是关于网易企业邮箱发邮件的问题
我搜了一下,发现问的人蛮多的,但是解决就没有下文了

问题一,群发(一条一条的发)如何等邮件发完,再发第二条,
Application.ProcessMessages;
sleep(5000);
有时一封邮件发得快,马上就发完了,但有时发得慢,这个两语句就显得不灵活了,能否得知发完了,再发邮件呢控制语句

问题二,群发,发到两三百条邮件就抛出connection closed gracefully,有没有好的办法
delphi 通过smpt服务器发送邮 XP 控件TidMesssge SMPT



问题三,邮件正文不用网页格式,字体可以不同颜色,及大小吗
...全文
5857 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
「已注销」 2011-05-07
  • 打赏
  • 举报
回复
with AidSMTP do
begin
try
if Connected then Disconnect;
Host := AIP;
Port := StrToInt(APort);
Username := AUser;
Password := APass;
AuthenticationType := atLogin;
Connect();
Authenticate;
result := Connected;
except
on e: Exception do
AErrText := e.Message;
end;
end;
sxper 2011-04-21
  • 打赏
  • 举报
回复

新建一Project1,在form1中添加控件statusbar1(Win32页)和控件IdIPWatch1(Indy Misc页)。接着设置好控件属性:在statusbar1的panels中添加0-TStatusPanel和1-TStatusPanel两项;IdIPWatch1的HistoryEnabled的属性设为False。

  编写代码:在TForm1.FormCreate(Sender: TObject)中加入以下代码:

statusbar1.Panels[1].Text:=IdIPWatch1.LocalIP;

  OK!按下F9功能键,运行程序,看一下窗口下边状态栏中是不是已经显示了本机的IP地址了?

  提示:若IdIPWatch1的HistoryEnabled的属性设为True,则会在程序退出时,自动生成一个文件(文件名为HistoryFileName属性设定的值),记录当前的IP地址。

//********************************************
//声明 : 请转载的朋友不要删除这段声明,谢谢合作!
//作者 : 雨中太阳
//网站 : http://www.SearchAll.cn
//邮箱 : sjt61991@163.com
//Q Q : 48572512
//********************************************
一、用Delphi7上控件 TidMessage,TidSMTP来发送电子邮件(编写:雨中太阳):
定义变量
UserEmail:string;//收件人邮件地址
SmtpAuthType:integer;//验证
SmtpServerUser:string;//登陆SMTP服务器的用户名
SmtpServerPassword:string;//登陆SMTP服务器用到的密码
SmtpServerName:string;//SMTP服务器名.例如:smtp.sohu.com
SmtpServerPort:integer;//SMTP服务器端口,默认的是25
以下是发送过程.其中idMsgSend:TidMessage,SMTP:TidSMTP;分别在Indy Clients和Indy Misc页上.
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
with IdMsgSend do
begin
Body.Assign(Memo1.Lines);
From.Text := 'sjt61991@sohu.com'; //发件人
ReplyTo.EMailAddresses :=UserEmail ;
Recipients.EMailAddresses :=UserEmail; { To: header }//收件人地址
Subject := 'kkkkkkkkkkk'; { Subject: header } //邮件主体
// Priority := TIdMessagePriority(cboPriority.ItemIndex); { Message Priority } //邮件优先级
// CCList.EMailAddresses := edtCC.Text; {CC} //抄送
// BccList.EMailAddresses := edtBCC.Text; {BBC} //暗送
if chkReturnReciept.Checked then //需要已读回执
begin {We set the recipient to the From E-Mail address }
ReceiptRecipient.Text := From.Text;
end
else
begin {indicate that there is no receipt recipiant}
ReceiptRecipient.Text := '';
end;
end;

authentication settings //是否需要验证
case SmtpAuthType of
0: SMTP.AuthenticationType := atNone;
1: SMTP.AuthenticationType := atLogin; {Simple Login }
end;
SMTP.Username := SmtpServerUser;
SMTP.Password := SmtpServerPassword;

{General setup}
SMTP.Host := SmtpServerName;
SMTP.Port := SmtpServerPort;

{now we send the message}
SMTP.Connect;

try
SMTP.Send(IdMsgSend);
showmessage('发送成功!');
finally

SMTP.Disconnect;
showmessage('发送失败!');
end;
end;
//二、判断是否是邮件地址
function IsEMail(EMail: String): Boolean;
var
s: String;
ETpos: Integer;
begin
ETpos:= pos('@',EMail);
if ETpos > 1 then
begin
s:= copy(EMail,ETpos+1,Length(EMail));
if (pos('.',s) > 1) and (pos('.',s) < length(s)) then
Result:= true
else Result:= false;
end
else
Result:= false;
end;
//三、根据输入的邮件地址从POP,SMTP地址中取得POP3,和 SMTP的地址.如果返回空,则是没有找到,可能是没有收录.
//地址的格式为.从FoxMail5.0得来的.
{/////////////////////////////////////////////////////////
foxmail.com.cn<p>pop.foxmail.com.cn<s>smtp.foxmail.com.cn
mail.bodachina.com<p>mail.bodachina.com<s>mail.bodachina.com
21cn.com<p>pop.21cn.com<s>smtp.21cn.com
}////////////////////////////////////////////////////////////
function GetPOPandSMTPFromTxt(FileName, EmailStr: string): string;
var
i,lenStr:integer;
AtEmail,TempStr,POPStr,SMTPStr:string;
myFile:TextFile;
begin
Result:='';
lenStr:=Pos('@',EmailStr);
AtEmail:=Copy(EmailStr,lenStr+1,Length(EmailStr)-lenStr);
AssignFile(myFile,FileName);
Reset(myFile);
While not Eof(myFile) do
begin
Readln(myFile,TempStr);
if AtEmail=Copy(TempStr,1,Pos('<p>',TempStr)-1) then
begin
POPStr:=Copy(TempStr,Pos('<p>',TempStr)+3,Pos('<s>',TempStr)-Pos('<p>',TempStr)-3);
SMTPStr:=Copy(TempStr,Pos('<s>',TempStr)+3,length(TempStr)-Pos('<s>',TempStr)-2);
Result:=POPStr+'|'+SMTPStr;
end;
end;
CloseFile(myFile);
end;
//用法如下:
procedure TForm1.Button2Click(Sender: TObject);
var
POPStr,SMTPStr,myResult:string;
begin
myResult:=GetPOPandSMTPFromTxt('E:\我的程序\popnsmtp.TXT',Edit1.Text);
if myResult<>''then
begin
POPStr:=Copy(myResult,1,Pos('|',myResult)-1);
SMTPStr:=Copy(myResult,Pos('|',myResult)+1,length(myResult));
showmessage(POPSTr);
showmessage(SMTPStr);
end;
end;
sxper 2011-04-21
  • 打赏
  • 举报
回复

新建一Project1,在form1中添加控件statusbar1(Win32页)和控件IdIPWatch1(Indy Misc页)。接着设置好控件属性:在statusbar1的panels中添加0-TStatusPanel和1-TStatusPanel两项;IdIPWatch1的HistoryEnabled的属性设为False。

  编写代码:在TForm1.FormCreate(Sender: TObject)中加入以下代码:

statusbar1.Panels[1].Text:=IdIPWatch1.LocalIP;

  OK!按下F9功能键,运行程序,看一下窗口下边状态栏中是不是已经显示了本机的IP地址了?

  提示:若IdIPWatch1的HistoryEnabled的属性设为True,则会在程序退出时,自动生成一个文件(文件名为HistoryFileName属性设定的值),记录当前的IP地址。

//********************************************
//声明 : 请转载的朋友不要删除这段声明,谢谢合作!
//作者 : 雨中太阳
//网站 : http://www.SearchAll.cn
//邮箱 : sjt61991@163.com
//Q Q : 48572512
//********************************************
一、用Delphi7上控件 TidMessage,TidSMTP来发送电子邮件(编写:雨中太阳):
定义变量
UserEmail:string;//收件人邮件地址
SmtpAuthType:integer;//验证
SmtpServerUser:string;//登陆SMTP服务器的用户名
SmtpServerPassword:string;//登陆SMTP服务器用到的密码
SmtpServerName:string;//SMTP服务器名.例如:smtp.sohu.com
SmtpServerPort:integer;//SMTP服务器端口,默认的是25
以下是发送过程.其中idMsgSend:TidMessage,SMTP:TidSMTP;分别在Indy Clients和Indy Misc页上.
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
with IdMsgSend do
begin
Body.Assign(Memo1.Lines);
From.Text := 'sjt61991@sohu.com'; //发件人
ReplyTo.EMailAddresses :=UserEmail ;
Recipients.EMailAddresses :=UserEmail; { To: header }//收件人地址
Subject := 'kkkkkkkkkkk'; { Subject: header } //邮件主体
// Priority := TIdMessagePriority(cboPriority.ItemIndex); { Message Priority } //邮件优先级
// CCList.EMailAddresses := edtCC.Text; {CC} //抄送
// BccList.EMailAddresses := edtBCC.Text; {BBC} //暗送
if chkReturnReciept.Checked then //需要已读回执
begin {We set the recipient to the From E-Mail address }
ReceiptRecipient.Text := From.Text;
end
else
begin {indicate that there is no receipt recipiant}
ReceiptRecipient.Text := '';
end;
end;

authentication settings //是否需要验证
case SmtpAuthType of
0: SMTP.AuthenticationType := atNone;
1: SMTP.AuthenticationType := atLogin; {Simple Login }
end;
SMTP.Username := SmtpServerUser;
SMTP.Password := SmtpServerPassword;

{General setup}
SMTP.Host := SmtpServerName;
SMTP.Port := SmtpServerPort;

{now we send the message}
SMTP.Connect;

try
SMTP.Send(IdMsgSend);
showmessage('发送成功!');
finally

SMTP.Disconnect;
showmessage('发送失败!');
end;
end;
//二、判断是否是邮件地址
function IsEMail(EMail: String): Boolean;
var
s: String;
ETpos: Integer;
begin
ETpos:= pos('@',EMail);
if ETpos > 1 then
begin
s:= copy(EMail,ETpos+1,Length(EMail));
if (pos('.',s) > 1) and (pos('.',s) < length(s)) then
Result:= true
else Result:= false;
end
else
Result:= false;
end;
//三、根据输入的邮件地址从POP,SMTP地址中取得POP3,和 SMTP的地址.如果返回空,则是没有找到,可能是没有收录.
//地址的格式为.从FoxMail5.0得来的.
{/////////////////////////////////////////////////////////
foxmail.com.cn<p>pop.foxmail.com.cn<s>smtp.foxmail.com.cn
mail.bodachina.com<p>mail.bodachina.com<s>mail.bodachina.com
21cn.com<p>pop.21cn.com<s>smtp.21cn.com
}////////////////////////////////////////////////////////////
function GetPOPandSMTPFromTxt(FileName, EmailStr: string): string;
var
i,lenStr:integer;
AtEmail,TempStr,POPStr,SMTPStr:string;
myFile:TextFile;
begin
Result:='';
lenStr:=Pos('@',EmailStr);
AtEmail:=Copy(EmailStr,lenStr+1,Length(EmailStr)-lenStr);
AssignFile(myFile,FileName);
Reset(myFile);
While not Eof(myFile) do
begin
Readln(myFile,TempStr);
if AtEmail=Copy(TempStr,1,Pos('<p>',TempStr)-1) then
begin
POPStr:=Copy(TempStr,Pos('<p>',TempStr)+3,Pos('<s>',TempStr)-Pos('<p>',TempStr)-3);
SMTPStr:=Copy(TempStr,Pos('<s>',TempStr)+3,length(TempStr)-Pos('<s>',TempStr)-2);
Result:=POPStr+'|'+SMTPStr;
end;
end;
CloseFile(myFile);
end;
//用法如下:
procedure TForm1.Button2Click(Sender: TObject);
var
POPStr,SMTPStr,myResult:string;
begin
myResult:=GetPOPandSMTPFromTxt('E:\我的程序\popnsmtp.TXT',Edit1.Text);
if myResult<>''then
begin
POPStr:=Copy(myResult,1,Pos('|',myResult)-1);
SMTPStr:=Copy(myResult,Pos('|',myResult)+1,length(myResult));
showmessage(POPSTr);
showmessage(SMTPStr);
end;
end;
lcjmy 2011-04-15
  • 打赏
  • 举报
回复
to 你确定是这个是标题过长的问题吗,
我用我自已的群发软件测试过了,
这是一封测式邮件,this is test eamil0x1114ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff

好像没有你说的那样的问题?
你是不是在你的代码里写错了吗,这个写代码跟顺序也有关系的
lcjmy 2011-04-14
  • 打赏
  • 举报
回复
抱歉了,我也不是高手了,不知道你的标题有多长
浩南_哥 2011-04-14
  • 打赏
  • 举报
回复
十几个汉字+一些字母+一些数字,总长度已超过好像是70多吧(每个汉字按2个长度),邮件就出现问题了。
当时比较急还发了个帖子,不过当时没有解决,后来才知道是因为标题过长。。。。
http://topic.csdn.net/u/20110302/16/7867e40f-2c53-4320-8dab-7b2732ee6294.html
浩南_哥 2011-04-13
  • 打赏
  • 举报
回复
既然你知道原因了,那就更好办了,捕获到异常的时候分这三种情况来处理吧。
看来楼主邮箱操作的高手啊。不知道楼主遇到过标题过长的问题没有?
lcjmy 2011-04-13
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 m617105 的回复:]
问题一:用多线程发送邮件,设置信号量来控制下一封邮件发送的时机,控件本身有个工作开始和结束的事件,可以在结束的时候来修改信号量。
问题二:我确实没遇到过,因为我发的少,是不是可以捕获到这个异常之后,断开连接,然后重新连接服务器,然后继续发送。
[/Quote]
问题二:我确实没遇到过,因为我发的少,是不是可以捕获到这个异常之后,断开连接,然后重新连接服务器,然后继续发送。
第二个问题产生的原因有几个,1.收邮件地址错误时会出现,2.服务器太忙时也会出现,3邮件发件频率太强了也会出现
浩南_哥 2011-04-13
  • 打赏
  • 举报
回复
问题一:用多线程发送邮件,设置信号量来控制下一封邮件发送的时机,控件本身有个工作开始和结束的事件,可以在结束的时候来修改信号量。
问题二:我确实没遇到过,因为我发的少,是不是可以捕获到这个异常之后,断开连接,然后重新连接服务器,然后继续发送。
lcjmy 2011-04-13
  • 打赏
  • 举报
回复
请晴天进来领分好了,
lcjmy 2011-04-13
  • 打赏
  • 举报
回复
呵呵,没有人回答,
谁进来领分啊,

1,593

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 网络通信/分布式开发
社区管理员
  • 网络通信/分布式开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧