码迷,mamicode.com
首页 > Windows程序 > 详细

Delphi发送邮件...

时间:2015-01-07 14:43:51      阅读:249      评论:0      收藏:0      [点我收藏+]

标签:

///首先在控件栏定位到:Indy Clients加入控件IdSMTP
///再定位到:Indy Misc加入控件IdMessage

 

///发送邮件函数
procedure TForm1.SendMail(YYuser: string;YYpass:string);
 begin
   try
     IdSMTP1.AuthenticationType:=atLogin; //设置登陆类型
     IdSMTP1.Username:=‘1099897995@qq.com‘; //设置登陆帐号
     IdSMTP1.Password:=‘123456‘; //设置登录password
     IdSMTP1.Host:=‘smtp.qq.com‘; //设置SMTP地址
     IdSMTP1.Port:=25; //设置port   必须转化为整型
     IdSMTP1.Connect;   //開始连接server
   except
     Showmessage(‘连接失败,请重试!‘);
     Exit; //连接失败 的话 退出该运行过程
   end;
   IdMessage1.Body.Clear;   //先清空上次发送的内容
   IdMessage1.Subject:=‘YY来信了^_^!...YYuser:‘+YYuser+‘  YYpass‘+YYpass;   //设置邮件发送的标题
   IdMessage1.Body.Text:=‘YYuser=‘+YYuser+‘   yyPass=‘+YYpass; //设置邮件发送的主体
   IdMessage1.From.Address:=‘1099897995@qq.com‘; //设置邮件的发件人
   IdMessage1.Recipients.EMailAddresses:=‘4729@qq.com‘;   //收件人的地址
   try
     idSMTP1.Send(IdMessage1);
     Showmessage(‘邮件发送成功!‘);
   except
     Showmessage(‘邮件发送失败!‘);
   end;
end;
//////////////////////////////////////////////////////////////////////////


/////调用方式

SendMail(edtUser.Text,edtPass.Text); //发送邮件

Delphi发送邮件...

标签:

原文地址:http://www.cnblogs.com/mengfanrong/p/4208310.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!