Convert email files to PDF
Document Engine supports converting email files such as EML and MSG to PDF. As of Document Engine 1.16.0, you can also control the language and timezone used when rendering email headers and timestamps.
Email conversion options
When you convert an email file through the Build API, you can set these file-part options. These options are supported only for email files (EML and MSG):
email_language— A BCP 47 language tag used for translated email header labels and date/time formatting.email_timezone— An IANA timezone name used for rendering email timestamps.
If you omit these options:
email_languagedefaults toen-USemail_timezonedefaults toUTC
Example: Convert an email with default English formatting
{ "parts": [ { "file": "email", "email_language": "en-US", "email_timezone": "UTC" } ]}This renders labels such as From, To, and Subject, and it formats timestamps in UTC.
Example: Convert an email with German formatting
{ "parts": [ { "file": "email", "email_language": "de-DE", "email_timezone": "Europe/Prague" } ]}This renders labels such as Von, An, and Betreff, and it formats timestamps using the Prague timezone.
Example request
Use the email file as a normal Build API file part and add the email-specific options:
curl -X POST http://localhost:5000/api/build \ -H "Authorization: Token token=<API token>" \ -F email=@/path/to/example.eml \ -F instructions='{ "parts": [ { "file": "email", "email_language": "de-DE", "email_timezone": "Europe/Prague" } ]}' \ -o result.pdfPOST /api/build HTTP/1.1Content-Type: multipart/form-data; boundary=customboundaryAuthorization: Token token=<API token>
--customboundaryContent-Disposition: form-data; name="email"; filename="example.eml"Content-Type: message/rfc822
<email data>--customboundaryContent-Disposition: form-data; name="instructions"Content-Type: application/json
{ "parts": [ { "file": "email", "email_language": "de-DE", "email_timezone": "Europe/Prague" } ]}--customboundary--For supported email file types, refer to the file type support guide.