.net SMTP 发送邮件
using System.Net.Mail; public static bool SendMail(string messTo,string messBody) { MailMessage mess = new MailMessage(); mess.From = new MailAddress("mmm306306@163.com", "报警系统");//发件人 mess.Subject = "报警系统";//主题 mess.IsBodyHtml = true;//允许HTML mess.BodyEncoding = System.Text.Encoding.UTF8;//编码 mess.Body = messBody; SmtpClient client = new SmtpClient();//new 出 客服端的 smtp client.Host = "smtp.163.com"; client.Credentials = new System.Net.NetworkCredential("mmm306306", "xxxxxxxxx");//需要发件人的账号 密码 mess.To.Add(new MailAddress(messTo));//收件人 数组(可以群发) try { client.Send(mess); return true; } catch (Exception ex) { return false; } }