delphi 发邮件

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:
相关日志:
评论: 0 | 引用: 0 | 查看次数:
发表评论
昵 称:
邮 箱:
主 页:
验证码:
内 容: