public void MailSend(string email)
{
MailMessage MyMail = new MailMessage();
MyMail.From = new MailAddress("服務端郵箱地址", "展示名稱,也可以為空");
MyMail.To.Add(new MailAddress(email));//emial 客戶端郵箱地址
MyMail.Subject = "check";//郵件標題
StringBuilder contentBuilder = new StringBuilder();
contentBuilder.Append("請單擊以下鏈接完成激活");
contentBuilder.Append("<a href='http://localhost:4064/Account2/repassword?email=" + email + "'>激活</a>");
MyMail.Body = contentBuilder.ToString();
MyMail.IsBodyHtml = true;
SmtpClient smtpclient = new SmtpClient();
//發件郵箱和密碼 ,注意這里要與發件人地址的郵箱一致
smtpclient.Credentials = new System.Net.NetworkCredential("服務端郵箱地址", "郵箱地址的密碼");
smtpclient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpclient.Host = "smtp.ym.163.com";//企業郵箱的站點,不同郵箱這個位置不同
smtpclient.EnableSsl = true;
{
MailMessage MyMail = new MailMessage();
MyMail.From = new MailAddress("服務端郵箱地址", "展示名稱,也可以為空");
MyMail.To.Add(new MailAddress(email));//emial 客戶端郵箱地址
MyMail.Subject = "check";//郵件標題
StringBuilder contentBuilder = new StringBuilder();
contentBuilder.Append("請單擊以下鏈接完成激活");
contentBuilder.Append("<a href='http://localhost:4064/Account2/repassword?email=" + email + "'>激活</a>");
MyMail.Body = contentBuilder.ToString();
MyMail.IsBodyHtml = true;
SmtpClient smtpclient = new SmtpClient();
//發件郵箱和密碼 ,注意這里要與發件人地址的郵箱一致
smtpclient.Credentials = new System.Net.NetworkCredential("服務端郵箱地址", "郵箱地址的密碼");
smtpclient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpclient.Host = "smtp.ym.163.com";//企業郵箱的站點,不同郵箱這個位置不同
smtpclient.EnableSsl = true;
smtpclient.Send(MyMail);
}
}