asp.net MVC 发送邮件
@try {
System.Net.Mail.MailAddress from = new System.Net.Mail.MailAddress("www.zzzyk.com", "ethan"); //填写电子邮件地址,和显示名称
System.Net.Mail.MailAddress to = new System.Net.Mail.MailAddress(www.zzzyk.com, "jimmy"); //填写邮件的收件人地址和名称
//设置好发送地址,和接收地址,接收地址可以是多个
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
mail.From = from;
mail.To.Add(to);
mail.Subject = "主题内容";
mail.Body = "你好";
mail.IsBodyHtml = true;//设置显示htmls
//设置好发送邮件服务地址
System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
client.Host = "smtp.163.com";
//填写服务器地址相关的用户名和密码信息
client.Credentials = new System.Net.NetworkCredential("www.zzzyk.com", "******");
//发送邮件
client.Send(mail);
}
catch {
@:<b>发送失败</b>
}
作者:Cai_Ethan
补充:Web开发 , ASP.Net ,