示例#1
0
        private void ServiceNotification(NotificationEmail notification)
        {
            EmailMessage message;

            try
            {
                message = new EmailMessage
                {
                    Body      = notification.Body,
                    FromEmail = (notification.FromEmail ?? _settings.EmailNotificationIssuedFrom).ToString(),
                    FromName  = notification.FromName,
                    Subject   = notification.Subject,
                    ToEmail   = notification.ToEmail.ToString()
                };
            }
            catch (Exception exception)
            {
                _logger.Error(string.Format("Could not create message for notifcation {0} to {1}", notification.Id, notification.ToEmail), exception);
                throw;
            }

            try
            {
                _notificationEmailSender.SendEmail(message);
            }
            catch (Exception exception)
            {
                string errorMessage = string.Format("Could not send email for notification {0} to {1}", notification.Id, message.ToEmail);
                _logger.Error(errorMessage, exception);
                _logger.Error("Message: " + exception.Message);
                _logger.Error("StackTrace: " + exception.StackTrace);
                throw;
            }
        }