Example #1
0
        private static IFluentEmail FillFluentEmail(ITemplate template, IFluentEmail fluentEmail, object htmlModel = null, object plainModel = null)
        {
            if (!string.IsNullOrEmpty(template.HtmlBodyTemplate))
            {
                if (htmlModel != null)
                {
                    fluentEmail.UsingTemplate(template.HtmlBodyTemplate, htmlModel);
                }
                else
                {
                    fluentEmail.Body(template.HtmlBodyTemplate, true);
                }
            }

            if (!string.IsNullOrEmpty(template.PlainBodyTemplate))
            {
                if (plainModel != null)
                {
                    fluentEmail.PlaintextAlternativeUsingTemplate(template.PlainBodyTemplate, plainModel);
                }
                else
                {
                    fluentEmail.PlaintextAlternativeBody(template.PlainBodyTemplate);
                }
            }

            if (!string.IsNullOrEmpty(template.Subject))
            {
                fluentEmail.Subject(template.Subject);
            }

            if (!string.IsNullOrEmpty(template.FromAddress))
            {
                fluentEmail.SetFrom(template.FromAddress);
            }

            fluentEmail.Data.Priority = template.Priority;

            if (!string.IsNullOrEmpty(template.Tag))
            {
                fluentEmail.Tag(template.Tag);
            }

            return(fluentEmail);
        }