当前位置:编程文档 >> DELPHI >> Delphi2006利用indy10实现SMTP发送邮件
首页

Delphi2006利用indy10实现SMTP发送邮件

所属类别:DELPHI
推荐指数:★★★☆
文档人气:22
本周人气:5
发布日期:2008-8-17

var
IdMessage1: TIdMessage;
IdSASLLogin1: TIdSASLLogin;
IdSMTP1: TIdSMTP;
LHlogin: TIdUserPassProvider;
begin
result:=0;
idMessage1:=TIdMessage.Create();
IdSASLLogin1:=TIdSASLLogin.Create();
IdSMTP1:=TIdSMTP.Create();
LHlogin:=TIdUserPassProvider.Create();
with idMessage1 do
begin
ContentType:='text/html';
Body.LoadFromFile(STRfname);
From.Address:=STRfromEMail;
Recipients.EMailAddresses:=STRReEmail;
IDMessage1.Subject:=STRsubject;
end;
with IDSMTP1 do
begin
Host:=STRHost;
port:=INTport;
username:=STRusername;
password:=STRpassword;
LHlogin.Username:=STRuserName;
LHlogin.Password:=STRpassWord;
IDSMTP1.AuthType:=atSASL;
IDSMTP1.SASLMechanisms.Add.SASL:=IdSASLLogin1;
IdSASLLogin1.UserPassProvider:=LHlogin;
try
idsmtp1.Connect;
idsmtp1.Authenticate;
idsmtp1.Send(idMessage1);
idsmtp1.Disconnect;
result:=1;
finally
end;
end;
idMessage1.Free;
IdSASLLogin1.Free;
IdSMTP1.Free;
LHlogin.Free;
end;

文档说明:

     

相关文档


读取评论列表……