NodeJS Preview feature for Emails

Currently we have a NodeJS process with a “Create Preview PDF” to preview standard letter documents. It works well, as I can call this from a simple web page and view the content of the letter.

Is there some advice that can be shared about creating a preview for Emails? As emails do not conform to standard letter formats, I expect the returned format should instead be HTML, but all embedded and encoded images will most likely be lost.

Thanks

You can use the Render Email Content task. Make sure to tick the Render messages in EML format option.

Immediately after, use the Download Email Messages task to obtain the EML file.

If you are rendering multiple emails, you will have to use a Metadata sequencer task in between, to loop through the list of email files in the metadata. More information is available in this online help page.

Hi Phil,

Thanks for your reply. Currently when I use this approach, I’m using a predefined XML structure, which is parsed through a Data Mapper before being sent to “Render Email Content”. I getting an error

[0050] W3602 : Error 0 on line 385, column 9: Microsoft JScript runtime error: An error occurred; status = 500, response = An unspecified error occurred which was caused by ApplicationException: From email address is missing or invalid. (SRV000001)

May I please confirm where I can set the email ‘From’ field? I tried the Metadata Fields Management, but couldn’t work it out. Are there specs for the input fields of the “Render Email Content” task? I can only see in the online documentation that an error will be thrown when it is not provided. Is it possible to see the JScript which is uses to reverse engineer the specs?

image

Thanks again.

The ‘From’ field is in your template:

If you’re curious, the Render Email Content task simply calls one of our REST API methods. The REST API is documented here, see the REST API Reference and then Content Creation (Email) Service.

Note that the REST API also offers a way to generate an actual preview image for an email template.