.net active up mail 邮件发送

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ActiveUp.Net.Mail;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Send();
        }
        public static void Send()
        {
            Message mail = new Message();
            mail.From = new Address("from");
            mail.Charset = "utf-8";
            mail.ContentTransferEncoding = ContentTransferEncoding.Base64;
            mail.Date = System.DateTime.UtcNow;
            List<string> toList = new List<string>();
            toList.Add("tomail");
            //接收地址
            foreach (var to in toList)
            {
                mail.To.Add(to);
            }
          
              //标题  同时设置编码为utf-8
            mail.Subject = Codec.RFC2047Encode("test使用様", Encoding.UTF8.BodyName);
            //邮件内容
            mail.BodyHtml.Charset = "utf-8";
        
          
           string body="As promised, the requested document.<br/>RegardsJohn";
            mail.BodyHtml.Text =body;
                                         
            try
            {
                SmtpClient.SendSsl(mail, mailhost,userid, mailpass, SaslMechanism.Login);

            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}

posted @ 2016-05-26 17:19  公众号python学习开发  阅读(345)  评论(0编辑  收藏  举报