コード例 #1
0
ファイル: MailBodyBuilder.cs プロジェクト: rkranenb/bbqmail
        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());
        }
コード例 #2
0
ファイル: EmailService.cs プロジェクト: stepanfryd/Gaia
        /// <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);
        }