using System.Net;
using System.Net.Mail;
using System.IO;
/// <summary>
/// 发邮件
/// </summary>
/// <param name="subject">邮件主题</param>
/// <param name="body">邮件内容</param>
/// <param name="mailto">收件人地址(用;间隔)</param>
public static bool SendMail(string subject, string body, string mailto)
{
//创建一个MailMessage对象
MailMessage message = new MailMessage();
//赋给MailMessage对象属性
string[] mails = mailto.Split(';');
foreach (string mail in mails)
{
message.To.Add(new MailAddress(mail));
}
message.Subject = string.Format(subject);
message.Body = body;
message.BodyEncoding = Encoding.UTF8;
message.IsBodyHtml = true;
message.Priority = MailPriority.High;
//创建一个SmtpClient类实例
SmtpClient smtp = new SmtpClient();
try
{
smtp.Send(message);
return true;
}
catch
{
return false;
}
}