MSG (Outlook Emails) to PDF
Hi,
We have a repeated requirement with a lot of our clients to generate previews of MSG emails - the general use case is, they save their emails from Microsoft Outlook as MSG, and upload it to their systems. This is a propertiary Microsoft format, but many recent advancements in the https://github.com/TeamMsgExtractor/msg-extractor project look to make understanding and converting these files very simple.
Internally, this msg-extractor utility uses wkhtmltopdf, an abandoned HTML > PDF library - when the --pdf argument is specified - it isn't very good at all and has serious security flaws, alongside handling fonts badly (though this is probably fixable with the --wk-options argument?).
However, specifying the --html and --prepared-html options with the utility generate a folder of the same name of the MSG file provided to ingest, containing all image attachments, and an HTML file with relative links to the image files - and it looks great in Chrome. This would be absolutely perfect to pass to Gotenberg.
Setup:
- Download latest release of TeamMsgExtractor/msg-extractor
- Use w/
python -m extract_msg './test.msg' --html --prepared-html
I have tested this on some extremely large email chains, and it seems very reliable considering the nature of the format, and the project seems very active - though even if it wasn't, these files hardly have changed much and I'd argue there is a significant case to still render them.
To be clear, this isn't about converting .eml files, these are much simpler - this is about the propertiary Outlook Message Item format - the README of the extractor project contains much documentation about the format.
Happy to provide MSG files on request privately if you can't get access to these easily.
Would be interested to hear if anyone else has conquered this type of feature in their web applications, to preview these awkward file types? Sadly changing the system to force users to convert to PDF first isn't suitable for most of our clients as they have tens of years of MSG files in their system.
Source: gotenberg/gotenberg