首页 > 代码库 > 亲测可用的发送邮件方法分享
亲测可用的发送邮件方法分享
//发送邮件代码 public static void Sends(string email, string formto, string content, string body, string upass) { string name = "no_reply@xxxx.com"; 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需为真实的邮箱地址
亲测可用的发送邮件方法分享
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。