Ejemplo n.º 1
0
        /// <summary>
        /// 发送邮件
        /// </summary>
        /// <param name="box">邮件</param>
        /// <returns></returns>
        public virtual async Task SendAsync(EmailBox box)
        {
            var mail   = new MailMessage();
            var config = await ConfigProvider.GetConfigAsync();

            mail.From = new MailAddress(config.FromAddress, config.DisplayName);
            PaserMailAddress(box.To, mail.To);
            PaserMailAddress(box.Cc, mail.CC);
            PaserMailAddress(box.Bcc, mail.Bcc);
            PaserMailAddress(config.FromAddress, mail.ReplyToList);
            mail.Subject    = box.Subject;
            mail.Body       = box.Body;
            mail.IsBodyHtml = box.IsBodyHtml;
            HandlerAttachments(box.Attachments, mail.Attachments);
            await SendAsync(mail);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 发送邮件
        /// </summary>
        /// <param name="box">邮件</param>
        public virtual void Send(EmailBox box)
        {
            var mail   = new MailMessage();
            var config = ConfigProvider.GetConfig();

            mail.From = new MailAddress(config.FromAddress);
            PaserMailAddress(box.To, mail.To);
            PaserMailAddress(box.Cc, mail.CC);
            PaserMailAddress(box.Bcc, mail.Bcc);
            PaserMailAddress(config.FromAddress, mail.ReplyToList);
            mail.Subject    = box.Subject;
            mail.Body       = box.Body;
            mail.IsBodyHtml = box.IsBodyHtml;
            HandlerAttachments(box.Attachments, mail.Attachments);
            Send(mail);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 入队
 /// </summary>
 /// <param name="box">电子邮件</param>
 public void Enqueue(EmailBox box)
 {
     _provider.Enqueue(box);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 发送邮件
 /// </summary>
 /// <param name="box">电子邮件</param>
 protected abstract void SendMail(EmailBox box);
Ejemplo n.º 5
0
 /// <summary>
 /// 尝试出队,获取电子邮件
 /// </summary>
 /// <param name="box">电子邮件</param>
 /// <returns></returns>
 public bool TryDequeue(out EmailBox box)
 {
     return(MailQueue.TryDequeue(out box));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 入队
 /// </summary>
 /// <param name="box">电子邮件</param>
 public void Enqueue(EmailBox box)
 {
     MailQueue.Enqueue(box);
 }