码迷,mamicode.com
首页 > Windows程序 > 详细

c# 发送邮件

时间:2014-12-08 09:17:24      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   os   sp   on   div   log   bs   

 public static void SendMail(string to, string subject, string content)
        {
            content = string.Concat(content, Environment.NewLine, "注: 自动测试功能评估阶段,结果仅供参考。");
            SmtpClient smtp = new System.Net.Mail.SmtpClient();
            smtp.Host = "10.20.80.250";
            smtp.Credentials = new NetworkCredential("liguoqiang@yskj.com", "ligq01");
            //smtp.Send("liguoqiang@yskj.com", to, subject, content);
            MailMessage mail = new MailMessage();
            //mail.Sender = new MailAddress("liguoqiang@yskj.com", "系统运行环境检测", Encoding.UTF8);
            mail.From = new MailAddress("liguoqiang@yskj.com", "系统运行环境检测", Encoding.UTF8);
            //邮件接收人
            mail.To.Add(to);
            mail.Subject = subject;
            mail.SubjectEncoding = Encoding.UTF8;
            mail.Body = content;
            mail.BodyEncoding = Encoding.UTF8;
            mail.IsBodyHtml = true;
            smtp.Send(mail);
        }

 

c# 发送邮件

标签:style   blog   color   os   sp   on   div   log   bs   

原文地址:http://www.cnblogs.com/honghong75042/p/4150323.html

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