Beispiel #1
0
        public void Send(string templateName, dynamic model)
        {
            string textLocation;

            if (Cohort.Site.Email.Templates.TryGetValue(templateName, out textLocation))
            {
                textLocation = Cohort.Site.Email.BaseDirectory + textLocation;
                var htmlLocation = textLocation.Replace(".liquid", ".html.liquid");

                var textTemplate = LoadOrGetCachedTemplate(textLocation);
                var htmlTemplate = LoadOrGetCachedTemplate(htmlLocation);

                var hasText = textTemplate != null;
                var hasHtml = htmlTemplate != null;

                EmailMessage email = null;
                if (hasText && hasHtml)
                {
                    email = _composer.CreateCombinedEmail(htmlTemplate, textTemplate, model);
                }
                else if (hasText)
                {
                    email = _composer.CreateTextEmail(textTemplate, model);
                }
                else if (hasHtml)
                {
                    _composer.CreateHtmlEmail(htmlTemplate, model);
                }

                DeliverAndLog(email);
            }
            else
            {
                Logger.Warn("No email template named {0} found!");
            }
        }
Beispiel #2
0
 public EmailMessage CreateCombinedEmail(string htmlTemplate, string textTemplate, dynamic model)
 {
     return(_composer.CreateCombinedEmail(htmlTemplate, textTemplate, model));
 }