/// <summary>
/// 郵件服務器地址
/// </summary>
private static string MailServer = "smtp.qq.com";
/// <summary>
/// 用戶名
/// </summary>
private static string MailUserName = "[email protected]";
/// <summary>
/// 密碼
/// </summary>
private static string MailPassword = "sdfdsfdfsdfsdf";
/// <summary>
/// 名稱
/// </summary>
private static string MailName = "測試";
public static void SendThreadBy465(string to, string title, string body)
{
new Thread(new ThreadStart(delegate ()
{
try
{
System.Web.Mail.MailMessage mmsg = new System.Web.Mail.MailMessage();
//驗證
mmsg.Subject = title.Trim(); ;// "zhuti1";//郵件主題
mmsg.BodyFormat = System.Web.Mail.MailFormat.Html;
mmsg.Body = body;// "wqerwerwerwer";//郵件正文
mmsg.BodyEncoding = Encoding.UTF8;//正文編碼
mmsg.Priority = System.Web.Mail.MailPriority.High;//優先級
mmsg.From = MailUserName;//發件者郵箱地址
mmsg.To = to;//收件人收箱地址
mmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
//登陸名
mmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", MailUserName);
//登陸密碼
mmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", MailPassword);
mmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", 465);//端口
mmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "true");
System.Web.Mail.SmtpMail.SmtpServer = MailServer;
System.Web.Mail.SmtpMail.Send(mmsg);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
})).Start();
}