コード例 #1
0
ファイル: MailQueueManager.cs プロジェクト: evisional1/mixerp
        public async Task AddAsync()
        {
            this.Processor = EmailProcessor.GetDefault(this.Database);

            if (!this.IsEnabled())
            {
                return;
            }

            var config = new EmailConfig(this.Database, this.Processor);

            this.Email.ReplyTo     = this.Email.ReplyTo.Or("");
            this.Email.ReplyToName = this.Email.ReplyToName.Or("");

            if (string.IsNullOrWhiteSpace(this.Email.FromName))
            {
                this.Email.FromName = config.FromName;
            }

            if (string.IsNullOrWhiteSpace(this.Email.FromEmail))
            {
                this.Email.FromEmail = config.FromEmail;
            }

            var sysConfig = MessagingConfig.Get(this.Database);

            if (sysConfig.TestMode)
            {
                this.Email.IsTest = true;
            }

            if (this.IsValidEmail(this.Email.FromEmail) &&
                this.IsValidEmail(this.Email.SendTo))
            {
                await MailQueue.AddToQueueAsync(this.Database, this.Email).ConfigureAwait(false);
            }
        }