码迷,mamicode.com
首页 > 其他好文 > 详细

SendMail

时间:2015-10-30 20:14:56      阅读:232      评论:0      收藏:0      [点我收藏+]

标签:

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");
        }

 

SendMail

标签:

原文地址:http://www.cnblogs.com/caishuhua226/p/4924102.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!