Esempio n. 1
0
        public StatementMessage CreateMessage(Person person, string templateName, DateTime startDate)
        {
            var page = (StatementPage)TemplateService.Resolve(templateName, null);

            page.SetInfo(person, startDate);

            var images  = new EmailAttachmentImageService(ImagesPath);
            var content = page.RenderPage(images);

            if (!page.ShouldSend)
            {
                return(null);
            }

            var message = new StatementMessage(page, templateName)
            {
                From = BillingAddress, SubjectEncoding = Email.DefaultEncoding
            };

            var htmlContent = AlternateView.CreateAlternateViewFromString(content, Email.DefaultEncoding, "text/html");

            htmlContent.TransferEncoding = TransferEncoding.QuotedPrintable;
            htmlContent.LinkedResources.AddRange(images.Attachments);
            message.AlternateViews.Add(htmlContent);

            message.Subject = page.EmailSubject;

            return(message);
        }
Esempio n. 2
0
        public StatementMessage CreateMessage(Person person, string templateName, DateTime startDate)
        {
            var page = (StatementPage)TemplateService.Resolve(templateName, null);
            page.SetInfo(person, startDate);

            var images = new EmailAttachmentImageService(ImagesPath);
            var content = page.RenderPage(images);
            if (!page.ShouldSend) return null;

            var message = new StatementMessage(page, templateName) { From = BillingAddress, SubjectEncoding = Email.DefaultEncoding };

            var htmlContent = AlternateView.CreateAlternateViewFromString(content, Email.DefaultEncoding, "text/html");

            htmlContent.TransferEncoding = TransferEncoding.QuotedPrintable;
            htmlContent.LinkedResources.AddRange(images.Attachments);
            message.AlternateViews.Add(htmlContent);

            message.Subject = page.EmailSubject;

            return message;
        }