Is there any pure open source solution to parse Outlook msg format directly from Javascript and or NodeJS? I believe there is a need to support Outlook msg format in nodemailer, which at least parses eml correctly. So far I could not find a better approach than relying on the linux command line:
Use msgconvert linux command to go from msg to eml:
sudo apt install -y libemail-outlook-message-perl cd /tmp msgconvert test\ with\ html\ content.msg # creates test\ with\ html\ content.eml
Use https://github.com/nodemailer/mailparser to get the information from the eml, for example:
git clone https://github.com/nodemailer/mailparser.git npm install cd mailparser/examples node extractInfoFromEml.js /tmp/test\ with\ html\ content.eml
Below is the code for extractInfoFromEml.js (just simple.js but accepting an argument.
'use strict'; const util = require('util'); const fs = require('fs'); const simpleParser = require('../lib/simple-parser.js'); const args = process.argv.slice(2); const filePath = args[0]; let input = fs.createReadStream(filePath); simpleParser(input) .then(mail => { console.log(util.inspect(mail, false, 22)); }) .catch(err => { console.log(err); });
PS: Apparently nodemailer accepts just bugs, therefore I could not ask for a feature request in github.