/// <summary>
/// 邮件发送
/// </summary>
/// <param name="mailSubject">邮件标题</param>
/// <param name="mailContent">邮件内容</param>
/// <param name="Email">接收的邮箱</param>
/// <returns></returns>
public static bool SendEmail(string mailSubject, string mailContent,string Email)
{
string smtpServer = "smtp.qq.com";//发送邮件服务器
string mailFrom = "****@qq.com";//发送者邮箱地址
string userPassword ="********"; //发送者邮箱密码
string mailTo= Email;
bool reult = false;
string[] mailTos = mailTo.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
SmtpClient smtpClient = new SmtpClient();
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.Host = smtpServer;
smtpClient.Credentials = new System.Net.NetworkCredential(mailFrom, userPassword);
for (int i = 0; i < mailTos.Length; i++)
{
MailMessage mailMessage = new MailMessage(mailFrom, mailTos[i]);
mailMessage.Subject = mailSubject;
mailMessage.Body = mailContent;
mailMessage.BodyEncoding = Encoding.UTF8;
mailMessage.IsBodyHtml = true;
mailMessage.Priority = MailPriority.Low;
try
{
smtpClient.Send(mailMessage);
reult = true;
}
catch (SmtpException ex)
{
return false;
}
}
return reult;
}
10-04