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

C# Tips:发送邮件

时间:2016-11-22 17:15:42      阅读:198      评论:0      收藏:0      [点我收藏+]

标签:htm   c#   nbsp   企业   less   pcl   oem   password   ddr   

使用263企业邮箱发送邮件:

public static void Run(string fromEmailAddress, string password, string toEmailAddress,string subject,
            string body, string smtpHost = "smtp.263.net",int smtpPort=25)
        {
            MailMessage myMail = new MailMessage();
            myMail.From = new MailAddress(fromEmailAddress);
            myMail.To.Add(new MailAddress(toEmailAddress));
            myMail.Subject = subject;
            myMail.SubjectEncoding = Encoding.UTF8;
            myMail.Body = body;
            myMail.BodyEncoding = Encoding.UTF8;
            myMail.IsBodyHtml = true;
            SmtpClient smtp = new SmtpClient();
            smtp.Host = smtpHost;
            smtp.Port = smtpPort;
            smtp.Credentials = new NetworkCredential(fromEmailAddress, password);
            smtp.EnableSsl = true;
            smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
            smtp.Send(myMail);
        }

 

C# Tips:发送邮件

标签:htm   c#   nbsp   企业   less   pcl   oem   password   ddr   

原文地址:http://www.cnblogs.com/jane850113/p/6089660.html

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