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 ="
[email protected]";
Message.From = "
[email protected]";
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>");
}
}
这是我自己操作成功了的。不知是否对大家有好处。
本文地址:http://com.8s8s.com/it/it8437.htm