标签:
public ActionResult SendMail() { MailMessage mss = new MailMessage(); mss.From = new MailAddress("Grace_cai01@infosys.com"); mss.Body = "testtesttesttesttest"; mss.BodyEncoding = Encoding.UTF8; mss.IsBodyHtml = false; mss.To.Add(new MailAddress("Grace_cai01@infosys.com")); SmtpClient cliente = new SmtpClient(); cliente.Host = ConfigurationManager.AppSettings["Host"].ToString(); cliente.Port = int.Parse(ConfigurationManager.AppSettings["Port"].ToString()); cliente.UseDefaultCredentials = ConfigurationManager.AppSettings["EnableSsl"].ToString() == "0" ? false : true; cliente.EnableSsl = false; string Username = ConfigurationManager.AppSettings["Username"].ToString(); string Password = ConfigurationManager.AppSettings["Password"].ToString(); System.Net.NetworkCredential credenciais = new System.Net.NetworkCredential(Username, Password); cliente.Credentials = credenciais; cliente.Send(mss); return Content("ok"); }
标签:
原文地址:http://www.cnblogs.com/caishuhua226/p/4924102.html