public string Build(MailData data) { var template = new StringBuilder(templateProvider.GetTemplate(data.TemplateName)); template.Replace("{{FirstName}}", data.FirstName); template.Replace("{{Id}}", data.Id); return(template.ToString()); }
/// <summary> /// Send email /// </summary> /// <param name="sender"></param> /// <param name="recipients"></param> /// <param name="templateKey"></param> /// <param name="model"></param> /// <param name="attachments"></param> /// <param name="customHeaders"></param> /// <typeparam name="T"></typeparam> /// <returns></returns> public async Task SendEmailAsync <T>(MailAddress sender, MailAddress[] recipients, string templateKey, T model, Attachment[] attachments = null, IDictionary <string, string> customHeaders = null) { var messageTemplate = _templateProvider.GetTemplate(templateKey); await SendEmailAsync(sender, recipients, messageTemplate.Subject, messageTemplate.TemplatePlain, messageTemplate.TemplateHtml, model, templateKey, attachments, customHeaders); }