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>"); } } 相关文章: 2021-08-01 2022-12-23 2022-12-23 2021-08-07 2021-10-31 2022-01-24