using System.Web.Util;
using System.Web.Mail;
using System.Net;
private void Button2_Click(object sender, System.EventArgs e)
{
try
{
MailMessage Message = new MailMessage();
Message.To ="laihua0316@163.com";
Message.From = "laihua80316@163.com";
Message.Subject = "今天心情很好!!";
Message.Body ="祝大家工作愉快!!";
Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "laihua80316"); //
Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "******"); //
SmtpMail.SmtpServer = "smtp.163.com";
SmtpMail.Send(Message);
Response.Write("<script>alert('ok')</"+"script>");
}
catch
{
Response.Write("<script>alert('fail')</"+"script>");
}
}
这是我自己操作成功了的。不知是否对大家有好处。