/// <summary>
 /// Execute sending email notification
 /// </summary>
 /// <param name="emailNotificationData">Mail template</param>
 public bool SendMail(NotificationData emailNotificationData)
 {
     var emailTemplate = builder.BuildEmail(emailNotificationData);
     bool emailSendSuccess = true;
     foreach (var recipient in emailTemplate.RecipientContacts.Where(r => r != null))
     {
         try
         {
             SendMail(emailTemplate.Subject, emailTemplate.Message, recipient, emailTemplate.Sender, emailNotificationData.CopyTo,
                  emailNotificationData.AttachedImagePaths);
         }
         catch (SmtpFailedRecipientsException ex)
         {
             for (int i = 0; i < ex.InnerExceptions.Length; i++)
             {
                 SmtpStatusCode status = ex.InnerExceptions[i].StatusCode;
                 if (status == SmtpStatusCode.MailboxBusy || status == SmtpStatusCode.MailboxUnavailable)
                 {
                     //Logger.Info("Error | Delivery failed - retrying in 5 seconds.");
                 }
                 else
                 {
                     //Logger.Info("Error | Failed to deliver message to {0}", ex.InnerExceptions[i].FailedRecipient);
                 }
             }
             emailSendSuccess = false;
         }
         catch (Exception exception)
         {
             //Logger.Error("Error mail service", exception);
             emailSendSuccess = false;
         }
     }
     return emailSendSuccess;
 }
        public EmailNotificationTemplate BuildEmail(NotificationData emailNotificationData)
        {
            string message = string.Empty;

            var template = GetEmailTemplateByType(emailNotificationData.Type);
            message += Razor.Parse(template.Body, emailNotificationData.Placeholders);
            message = PreMailer.Net.PreMailer.MoveCssInline(message, removeStyleElements: true).Html;
            template.Subject = emailNotificationData.Placeholders.Subject;
            string filledSubject = template.Subject;

            return new EmailNotificationTemplate
            {
                Sender = ConfigurationHelper.GetSMTPUser(),
                Message = message,
                Subject = filledSubject,
                RecipientContacts = emailNotificationData.Recipients.ToList()
            };
        }
 public bool SendMail(NotificationData emailNotificationData)
 {
     return _emailTransport.SendMail(emailNotificationData);
 }