Javascript Outlook HTML Post Format

Is there any clean open source solution for parsing MS Outlook format directly from Javascript or NodeJS? I believe that it is necessary to support the Outlook MSG format in nodemailer, which at least correctly analyzes eml. So far, I could not find a better approach than relying on the linux command line:

  • Use the msgconvert linux command to switch 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 information from 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: Obviously, nodemailer only accepts errors, so I could not request a function request in github.

+1
source share

All Articles