.net发送邮件
public bool SendMail(string to, string from, string title, string content, string userName, string password, string smtpHost)
{
try
{
MailAddress mail_from = new MailAddress(from);
MailAddress mail_from = new MailAddress(from);
MailAddress mail_to = new MailAddress(to);
MailMessage message = new MailMessage(mail_from, mail_to);
message.Subject = title;
message.IsBodyHtml = true;
message.Body = content;
SmtpClient client = new SmtpClient(smtpHost);
client.Credentials = new System.Net.NetworkCredential(userName, password);
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.Send(message);
return true;
}
catch (Exception ex)
{
Response.Write("<script>alert('" + ex.Message + "')</script>");
return false;
}
}