/// <summary>
        /// Sends the email.
        /// </summary>
        /// <param name="template">The template.</param>
        /// <param name="recipients">The recipients.</param>
        private void SendEmail(IProcessedTemplate template, params string[] recipients)
        {
            if (recipients == null || template == null || string.IsNullOrEmpty(template.Body))
            {
                return;
            }
            var           isHtml  = template.Type != EmailTemplateTypes.Text;
            IEmailMessage message = new EmailMessage(recipients, template.Body, isHtml);

            message.Subject = template.Subject;
            var emailFromSetting = _appConfigRepository.Settings.FirstOrDefault(s => s.Name.Equals("DefaultEmailFrom"));

            if (emailFromSetting != null)
            {
                var emailFrom = emailFromSetting.SettingValues.FirstOrDefault();
                if (emailFrom != null)
                {
                    message.From = emailFrom.ToString();
                }
            }

            try
            {
                _emailService.SendEmail(message);
            }
            catch
            {
                //Log
                return;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Sends the email.
        /// </summary>
        /// <param name="template">The template.</param>
        /// <param name="recipient">The recipient.</param>
        private void SendEmail(IProcessedTemplate template, string recipient)
        {
            if (string.IsNullOrEmpty(recipient) || template == null || string.IsNullOrEmpty(template.Body))
            {
                return;
            }
            var           isHtml  = template.Type != EmailTemplateTypes.Text;
            IEmailMessage message = new EmailMessage(recipient, template.Body, isHtml);

            message.Subject = template.Subject;
            var eMessage    = new MailMessage();
            var smtpDefault = eMessage.From.ToString();

            message.From = string.IsNullOrWhiteSpace(smtpDefault) ? "*****@*****.**" : smtpDefault;

            try
            {
                _emailService.SendEmail(message);
            }
            catch
            {
                //Log
                return;
            }
        }