Custom Layout and Date Format for Email Converters
The EML and MSG converters now let you supply your own HTML layout for the converted email. TemplateFile takes an HTML page with placeholders for the header fields and the message body, replacing the built-in layout. DateTimeFormat sets how the sent date is printed. Both parameters are optional, so conversions that leave them out run exactly as before.
Highlights
- Both parameters are available on every EML and MSG converter, across the PDF, JPG, PNG, TIFF and WEBP outputs.
- A template is plain HTML with
{{subject}},{{from}},{{to}},{{cc}},{{sent}}and{{emailContent}}placeholders. Pass it as a URL or as file content. - The email body is rendered in its own isolated block, so the message CSS cannot affect your page and your CSS cannot affect the message.
TemplateFileapplies to the top-level email. Converted attachments keep the built-in layout, and they do followDateTimeFormat.- Setting
TemplateFileoverridesConvertHeader, because the template itself decides which header fields appear.
Parameters
TemplateFile(file,htmlorhtm) - the HTML page used to lay out the converted email. Defaults to the built-in template.DateTimeFormat(string) - a .NET custom date and time format for the sent date, for exampleyyyy-MM-dd HH:mm. Defaults to US style with a 12-hour clock.
Try it out
- EML to PDF - API sandbox: eml-to-pdf
- MSG to PDF - API sandbox: msg-to-pdf
- EML to PNG - API sandbox: eml-to-png
- MSG to PNG - API sandbox: msg-to-png