亲测可用的发送邮件方法分享
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了亲测可用的发送邮件方法分享相关的知识,希望对你有一定的参考价值。
//发送邮件代码 public static void Sends(string email, string formto, string content, string body, string upass) { string name = "[email protected]"; string smtp = "smtp.exmail.sina.com"; SmtpClient _smtpClient = new SmtpClient(); _smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network; _smtpClient.Host = smtp; _smtpClient.Credentials = new System.Net.NetworkCredential(name, upass); MailMessage _mailMessage = new MailMessage(); _mailMessage.From = new MailAddress(formto, "xxxx公司"); _mailMessage.To.Add(email); _mailMessage.SubjectEncoding = System.Text.Encoding.GetEncoding("gb2312"); _mailMessage.Subject = content; _mailMessage.Body = body; _mailMessage.BodyEncoding = System.Text.Encoding.GetEncoding("gb2312"); _mailMessage.IsBodyhtml = true; _mailMessage.Priority = MailPriority.High; }
注:formto需为真实的邮箱地址
以上是关于亲测可用的发送邮件方法分享的主要内容,如果未能解决你的问题,请参考以下文章
phpmailer 发送Outlook邮件时535 5.7.3 authentication unsuccessful错误的解决办法
phpmailer 发送Outlook邮件时535 5.7.3 authentication unsuccessful错误的解决办法