您的位置:首页 > 编程语言 > ASP

asp.net发送邮件

2010-07-27 13:19 337 查看
public bool sendMail(string strSmtp,string from,string to,string userName,string Password,string caption,string subject)
{
try
{
MailAddress mailFrom = new MailAddress(from);
MailAddress mailTo = new MailAddress(to);
MailMessage msg = new MailMessage(mailFrom, mailTo);
msg.Subject = caption;
msg.IsBodyHtml = true;
msg.Body = subject;

SmtpClient client = new SmtpClient(strSmtp);
client.Credentials = new System.Net.NetworkCredential(userName, Password);
client.Send(msg);
return true;
}
catch (Exception e1)
{
System.Web.HttpContext.Current.Response.Write(e1.Message);
return false;
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  asp.net string exception