Beispiel #1
0
        public Task SendEmailAsync(string email, string subject, string message, string template)
        {
            var strMessageBody = BuildEmailBody(message, template, subject);

            // Check for Default emails Sending Options from App settings
            if (_sendGridOptions.IsDefault)
            {
                _functionalSvc.SendEmailBySendGridAsync(_sendGridOptions.SendGridKey, _sendGridOptions.FromEmail, _sendGridOptions.FromFullName, subject, strMessageBody, email).Wait();
            }

            if (!_smtpOptions.IsDefault)
            {
                return(Task.CompletedTask);
            }

            if (!string.IsNullOrEmpty(strMessageBody))
            {
                // Then we need to send email using SMTP
                _functionalSvc.SendEmailByGmailAsync(_smtpOptions.FromEmail,
                                                     _smtpOptions.FromFullName,
                                                     subject,
                                                     strMessageBody,
                                                     email,
                                                     email,
                                                     _smtpOptions.SmtpUserName,
                                                     _smtpOptions.SmtpPassword,
                                                     _smtpOptions.SmtpHost,
                                                     _smtpOptions.SmtpPort,
                                                     _smtpOptions.SmtpSsl).Wait();
            }

            return(Task.CompletedTask);
        }
Beispiel #2
0
        public Task SendMailAsync(string email, string subject, string message, string template)
        {
            var messageBody = BuildEmailBody(message, template, subject);

            if (_sendGridOptions.IsDefault)
            {
                _functionalSvc.SendEmailBySendGridAsync(
                    _sendGridOptions.SendGridKey,
                    _sendGridOptions.FromEmail,
                    _sendGridOptions.FromFullName,
                    subject,
                    messageBody,
                    email).Wait();
            }

            if (_smtpOptions.IsDefault == false)
            {
                return(Task.CompletedTask);
            }

            if (string.IsNullOrEmpty(messageBody) == false)
            {
                _functionalSvc.SendEmailByGmailAsync(
                    _smtpOptions.FromEmail,
                    _smtpOptions.FromFullName,
                    subject,
                    messageBody,
                    email,
                    email,
                    _smtpOptions.SmtpUserName,
                    _smtpOptions.SmtpPassword,
                    _smtpOptions.SmtpHost,
                    _smtpOptions.SmtpPort,
                    _smtpOptions.SmtpSsl).Wait();
            }

            return(Task.CompletedTask);
        }