asp.Net送信メール
2368 ワード
~_~つのプログラマーの宝を洗う店:クリックしてリンクを開けます
/// <summary>
///
/// </summary>
/// <param name="subject"> </param>
/// <param name="content"> </param>
/// <param name="to"> </param>
/// <param name="fromdesc"> :</param>
/// <returns></returns>
public static string SendEmail2(string subject, string content, string to, string fromdesc, string guid)
{
string result = "0";
try
{
content = " :<br /> !<br /> , :";
to = to.Trim();
MailMessage mailMessage = new MailMessage();
mailMessage.From = new MailAddress("[email protected]", fromdesc);
mailMessage.To.Add(to);
mailMessage.Subject =subject.Replace(" ","");
mailMessage.IsBodyHtml = true;
//mailMessage.Priority = MailPriority.High;
mailMessage.BodyEncoding = System.Text.Encoding.UTF8;
mailMessage.Body = content;
mailMessage.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess;
SmtpClient smtpClient = new SmtpClient();
smtpClient.Host = "smtp.exmail.qq.com";
//smtpClient.Host = "smtp.163.com";
//smtpClient.Host = "smtp.exmail.sina.com";
smtpClient.Port = 25;
smtpClient.EnableSsl = true;
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = new System.Net.NetworkCredential(" ", " ");
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.Send(mailMessage);
result = "1";
}
catch(Exception ex)
{
result = "-1";
}
return result;
}