【C#使用Gmail发送邮件源代码分享】

复制代码
using System.Net.Mail;
try
{
MailMessage mailMessage
= new MailMessage();
mailMessage.To.Add(email);
mailMessage.From
= new System.Net.Mail.MailAddress("发送邮箱");
mailMessage.Subject
= Title;
mailMessage.Body
= Content;
mailMessage.IsBodyHtml
= true;
mailMessage.BodyEncoding
= System.Text.Encoding.UTF8;
mailMessage.Priority
= System.Net.Mail.MailPriority.Normal;

SmtpClient smtpClient
= new SmtpClient("587");
smtpClient.EnableSsl
= true;
smtpClient.Credentials
= new System.Net.NetworkCredential("帐号", "密码");

smtpClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtpClient.Host
= "smtp.gmail.com";
smtpClient.Send(mailMessage);
}
catch (Exception e)
{
throw e;
}
复制代码

posted on   BarneyZhang  阅读(558)  评论(0编辑  收藏  举报

< 2011年6月 >
29 30 31 1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 1 2
3 4 5 6 7 8 9

导航

统计

点击右上角即可分享
微信分享提示