/// <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); }
/// <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); }
/// <summary> /// 入队 /// </summary> /// <param name="box">电子邮件</param> public void Enqueue(EmailBox box) { _provider.Enqueue(box); }
/// <summary> /// 发送邮件 /// </summary> /// <param name="box">电子邮件</param> protected abstract void SendMail(EmailBox box);
/// <summary> /// 尝试出队,获取电子邮件 /// </summary> /// <param name="box">电子邮件</param> /// <returns></returns> public bool TryDequeue(out EmailBox box) { return(MailQueue.TryDequeue(out box)); }
/// <summary> /// 入队 /// </summary> /// <param name="box">电子邮件</param> public void Enqueue(EmailBox box) { MailQueue.Enqueue(box); }