Email macro rendering HTML

Ben Janssen asked on December 21, 2017 23:35

I am trying to include the order invoice in a email template that im sending with code.

Template:
{% Order.OrderInvoice #%}

Code:
EmailTemplateInfo mEmailTemplate = EmailTemplateProvider.GetEmailTemplate("OrderPaidToCompany", OrderObject.OrderSiteID);

EmailMessage message = new EmailMessage();
message.EmailFormat = EmailFormatEnum.Default;
message.Recipients = CustomCartData.Company.ContactEmail;
MacroResolver Resolver = MacroResolver.GetInstance();
Resolver.SetNamedSourceData("Order", OrderObject);
Resolver.SetNamedSourceData("Company", CustomCartData.Company);
Resolver.SetNamedSourceData("CompanyRole", CustomCartData.CompanyRole);
try {
// Send e-mail
EmailSender.SendEmailWithTemplateText(SiteInfoProvider.GetSiteName(OrderObject.OrderSiteID), message, mEmailTemplate, Resolver, false);
}
catch {
// Email sending failed EventLogProvider.LogEvent(EventType.ERROR, "SendOrderEmailToCompany", "Was Not able to send a copy of receipt to the company");
}

However when previewing the email in the Email Queue, the HTML is not rendering. Its just shows the html tags.

This same invoice (Order.OrderInvoice) is used in the order status update and order confirmation templates and it renders fine.

Thanks

Correct Answer

Jan Hermann answered on December 22, 2017 09:20

You can try this one instead:

{% Order.OrderInvoice|(encode)false %}

1 votesVote for this answer Unmark Correct answer

Recent Answers


Ben Janssen answered on December 22, 2017 15:33

Thank you Jan, this worked like a charm.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.