【C#使用Gmail发送邮件源代码分享】
时间:2011-06-13 来源:zhxhdean
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;
}
相关阅读 更多 +