【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 2011-06-13 15:38 BarneyZhang 阅读(558) 评论(0) 编辑 收藏 举报
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步