Outlook HTML msg format from Javascript

廉价感情. 提交于 2019-12-10 15:32:30

问题


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.

来源:https://stackoverflow.com/questions/47125889/outlook-html-msg-format-from-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!