delphi 发邮件
作者:小龙 日期:2012-1-7 0:46:41
procedure TForm1.Button1Click(Sender: TObject);
var
Attachment_name:String;
begin
//Attachment_name:='d:\attachment.rar';
IdSMTP1.AuthenticationType:=atLogin;
IdSMTP1.Host:='smtp.qq.com';
IdSMTP1.Port:=25;
IdSMTP1.Username:='1507250020@qq.com';
IdSMTP1.Password:=******;
IdMessage1.Body.add('测试中文4');
IdMessage1.From.Text:='1507250020@qq.com';
IdMessage1.Recipients.EMailAddresses:='54440294@qq.com';
//IdMessage1.CCList.EMailAddresses := edtCC.Text;// {CC}
//IdMessage1.BccList.EMailAddresses:='w@exel.com' //{BBC}
IdMessage1.Subject:='This is a test !';
if FileExists(Attachment_name) then TIdAttachment.Create(IdMessage1.MessageParts,Attachment_name);
try
IdSMTP1.Connect(-1);
IdSMTP1.Send(IdMessage1);
showmessage('OK');
except
showmessage('Error !');
end;
IdSMTP1.Disconnect;
end;
点击下载源码:email.zip
上一篇
下一篇
Tags: