예제 #1
0
        public async Task ProcessMailQueueAsync(IEmailProcessor processor)
        {
            IEnumerable <EmailQueue> queue = MailQueue.GetMailInQueue(Catalog).ToList();
            var config = new Config(Catalog);

            if (IsEnabled())
            {
                foreach (var mail in queue)
                {
                    var message     = EmailHelper.GetMessage(config, mail);
                    var host        = EmailHelper.GetSmtpHost(config);
                    var credentials = EmailHelper.GetCredentials(config);
                    var attachments = mail.Attachments?.Split(',').ToArray();

                    bool success = await processor.SendAsync(message, host, credentials, false, attachments);

                    if (!success)
                    {
                        continue;
                    }

                    mail.Delivered   = true;
                    mail.DeliveredOn = DateTime.UtcNow;


                    MailQueue.SetSuccess(this.Catalog, mail.QueueId);
                }
            }
        }
예제 #2
0
        public async Task ProcessMailQueueAsync(IEmailProcessor processor)
        {
            var queue  = MailQueue.GetMailInQueue(this.Database).ToList();
            var config = new Config(this.Database, this.Processor);

            if (this.IsEnabled())
            {
                foreach (var mail in queue)
                {
                    var message     = EmailHelper.GetMessage(config, mail);
                    var attachments = mail.Attachments?.Split(',').ToArray();

                    bool success = await processor.SendAsync(message, false, attachments);

                    if (!success)
                    {
                        continue;
                    }

                    mail.Delivered   = true;
                    mail.DeliveredOn = DateTimeOffset.UtcNow;


                    MailQueue.SetSuccess(this.Database, mail.QueueId);
                }
            }
        }