public async Task SendEmail(DeliveryInstructions instructions) { if (instructions.Enabled == false) { return; } var email = BuildEmailMessage(instructions); await mailer.SendEmail(email); }
private string BuildEmailBody(DeliveryInstructions instructions) { var brand = instructions.Brand; var messageName = instructions.MessageTemplate; // Pull up message template and apply the data var messagePath = ioService.CombineAndMap(EmailPath, BrandedMessageFolder, brand, messageName); var messageTemplate = ioService.ReadAllText(messagePath); var message = templateResolver.ResolveTemplate(messageTemplate, instructions.Parameters); // Pull up brand template and apply the message var brandTemplatePath = ioService.CombineAndMap(EmailPath, BrandedTemplateFolder, brand + ".cshtml"); var brandTemplate = ioService.ReadAllText(brandTemplatePath); var body = templateResolver.ResolveTemplate(brandTemplate, new { Body = message }); return body; }
private MailMessage BuildEmailMessage(DeliveryInstructions instructions) { var emailBody = BuildEmailBody(instructions); var email = new HtmlEmail(instructions, emailBody); return email; }
public HtmlEmail(DeliveryInstructions instructions, string body) : base(instructions.From.Address, instructions.GetDelimitedRecipients(","), instructions.Subject, body) { base.BodyEncoding = instructions.BodyEncoding; base.IsBodyHtml = true; }