Exemple #1
0
        private void Parse(EmailTemplate template, List <EmailFormattingError> errors)
        {
            Format(EmailJob.ForPreview, template, new App("1", default), new User("1", "1", default), errors);

            if (!string.IsNullOrWhiteSpace(template.BodyHtml))
            {
                var html = MjmlToHtml(template.BodyHtml, errors);

                var(body, error) = ParsedEmailTemplate.Create(html);

                if (error != null)
                {
                    errors.Add(new EmailFormattingError(error, EmailTemplateType.BodyHtml));
                }

                template.ParsedBodyHtml = body;
            }

            if (!string.IsNullOrWhiteSpace(template.BodyText))
            {
                var(body, error) = ParsedEmailTemplate.Create(template.BodyText);

                if (error != null)
                {
                    errors.Add(new EmailFormattingError(error, EmailTemplateType.BodyText));
                }

                template.ParsedBodyText = body;
            }

            if (errors.Count == 0 && template.ParsedBodyHtml == null && template.ParsedBodyText == null)
            {
                errors.Add(new EmailFormattingError(Texts.Email_TemplateUndefined, EmailTemplateType.General));
            }
        }
Exemple #2
0
        private string?FormatBodyHtml(ParsedEmailTemplate template, Dictionary <string, string?> properties, List <EmailJob> jobs, string emailAddress,
                                      List <EmailFormattingError> errors)
        {
            var result = template.Format(jobs, properties, emailAddress, true, imageFormatter);

            ValidateResult(result, jobs, errors, EmailTemplateType.BodyHtml);

            return(result);
        }