我的这段群发邮件代码如何改成多线程度。 ( 积分: 10 )

  • 主题发起人 主题发起人 51zhan.com
  • 开始时间 开始时间
5

51zhan.com

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TfrmMain.SendMail;
var
MxList: TStringList;
i: Integer;
QName, ThoughAddress: string;
sMX,sDomain:string;
lMX:TstringList;
FailNum,WinNum: integer;
IdSMTP1 : TIdSMTP;
IdMessage1: TIdMessage;
begin
{ 根据用户所填写的内容创建邮件 }
WinNum := 0;
FailNum := 0;
g1.MinValue := 0;
g1.MaxValue := intMailNum - 1;
g1.Visible := true;
for i:=0 to intMailNum-1do
begin
ThoughAddress := StrGrdEmail.Cells[0,i+1];
IdMessage1 := TIdMessage.Create(Application);
try
with IdMessage1do
begin
Body.Assign(mmContent.Lines);
//邮件正文
From.Address := Trim(edtFrom.Text);
//发件人地址
Recipients.EMailAddresses := ThoughAddress;//Trim(edtTo.Text);
//收件人地址
Subject := edtSubject.Text;
//邮件主题
end;
sDomain := EmailGetDomain(ThoughAddress);
if sDomain='' then
Exit;
lMX := TstringList.Create;
lMX := GetMxList('',sDomain);
try
if lMX.Count < 1 then
sMX := ''
else
sMX := lMX[0];
finally
lMX.Free;
end;


{ 发送邮件 }
IdSMTP1 := TIDSmtp.Create(Application);
try
with IdSMTP1do
begin
Host := sMX;
// 将Host赋值为目的地,这就是特快专递与普通邮件的区别
Port := 25;
// smtp服务默认的端口为25
try
Connect(5000);
//连接到服务器
except
end;
try
try
Send(IdMessage1);
//发送刚才创建的邮件
inc(WinNum);
Application.ProcessMessages;
StrGrdEmail.Cells[1,i+1] := '成功!';
lblWinNum.Caption := inttostr(WinNum);
except
inc(FailNum);
Application.ProcessMessages;
StrGrdEmail.Cells[1,i+1] := '失败!';
lblFailNum.Caption := inttostr(FailNum);
end;
finally
Disconnect;
//断开服务器连接
end;
end;
g1.Progress := i;
finally
IdSMTP1.Free;
end;
finally
IdMessage1.Free;
end;
end;
end;
 
如何解决?
 
好心人,谁能帮我解决!
 
救命啊?最近給Borland中國盯上了!請有正版Delphi使用授權的人幫助一下
QQ:10961560
 
我可以帮你个忙,你把邮件留下,我发你个demo
 
能否也给我发一份的 stevens@21cn.com
 
接受答案了.
 
能否也给我发一份:nanhang950333@163.com
 
后退
顶部