C# 使用网易邮箱发送邮件

代码如下,值得注意的有一下几点:
1.网易要求使用代理密码而不暴露邮箱密码
2.要求邮箱开通smtp服务
3.要求邮件发送者邮箱和认证的邮箱地址一致。
private void SendEmail(string title, string content)
{
MailMessage myMail = new MailMessage();
myMail.From = new MailAddress("test@163.com");
myMail.To.Add(new MailAddress("anni@qq.com"));
myMail.Subject = title;
myMail.SubjectEncoding = Encoding.UTF8;
myMail.Body = content;
myMail.BodyEncoding = Encoding.UTF8;
myMail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.163.com";
smtp.Credentials = new NetworkCredential("test@163.com", "代理密码");
smtp.Send(myMail);
}
上一篇:42. Trapping Rain Water


下一篇:Android中Local Service最本质的作用是什么?