示例#1
0
 private Library.Queue.Packet <QueueItem> ConvertToPacket(Core.Model.Mail mail)
 => new Library.Queue.Packet <QueueItem>
 {
     Label         = mail.ID.ToString("N"),
     AppSpecific   = 1,
     CorrelationId = mail.ID.ToString("N"),
     Id            = mail.ID,
     Priority      = (Library.Queue.Priority)((byte)mail.Priority),
     Data          = new QueueItem {
         SourceAccountID = mail.SourceAccountID, Mail = mail
     },
     TryCount = 0
 };
示例#2
0
        protected virtual Task <AppCore.Result> SendCoreAsync(Core.Model.Mail mail, Core.Model.Account account)
        {
            _client = new SmtpClient()
            {
                Host           = account.Host,
                Port           = account.Port,
                EnableSsl      = account.SSL,
                DeliveryMethod = SmtpDeliveryMethod.Network,
                Credentials    = new NetworkCredential(account.Email, account.Password),
                Timeout        = 20000
            };

            _message = new MailMessage()
            {
                Body            = mail.Content,
                BodyEncoding    = Encoding.UTF8,
                Subject         = mail.Subject,
                SubjectEncoding = Encoding.UTF8,
                From            = new MailAddress(account.Email),
                IsBodyHtml      = true
            };

            mail.EmailReceivers.ForEach(f =>
            {
                if (!String.IsNullOrEmpty(f.Email))
                {
                    _message.To.Add(f.Email);
                }
                if (!String.IsNullOrEmpty(f.Cc))
                {
                    _message.CC.Add(f.Cc);
                }
                if (!String.IsNullOrEmpty(f.Bcc))
                {
                    _message.Bcc.Add(f.Bcc);
                }
            });

            _client.SendMailAsync(_message);

            return(AppCore.Result.SuccessfulAsync());
        }
 public Task <AppCore.Result <Core.Model.Mail> > Send(Core.Model.Mail msg)
 => _mailService.SendAsync(msg);
示例#4
0
 public AppCore.Result Enqueue(Core.Model.Mail mail)
 {
     _queue.Enqueue(ConvertToPacket(mail));
     return(AppCore.Result.Successful());
 }