标签:
引用:
using System.Net.Mail;
public class EmailHelper { public static bool SendEmail(string title, string body, string address) { try { MailAddress from = new MailAddress("xxx@xxx.com", "xxx"); //发送源邮箱地址和名称 MailAddress to = new MailAddress(address); //接收者邮箱地址 MailMessage message = new MailMessage(from, to); //新建邮件 message.Subject = title; //邮件标题
message.Body = body; //邮件正文 message.IsBodyHtml = true; //邮件正文格式
using (SmtpClient client = new SmtpClient("255.255.255.255", 50)) //服务器和端口号 { client.Credentials = new System.Net.NetworkCredential("xxx", "password"); //用户名和密码 client.Send(message); } return true; } catch (Exception) { return false; } } }
C#System.Net.Mail采用简单邮件传输协议发送邮件
标签:
原文地址:http://www.cnblogs.com/RedSky/p/4689834.html