来自 Javascript 的 Outlook HTML msg 格式

Nes*_*iza 6 email outlook msg node.js nodemailer

是否有任何纯开源解决方案可以直接从 Javascript 和/或 NodeJS 解析 Outlook msg 格式?我相信需要在 nodemailer 中支持 Outlook msg 格式,它至少可以正确解析 eml。到目前为止,我找不到比依赖 linux 命令行更好的方法:

  • 使用 msgconvert linux 命令从 msg 转到 eml:

    sudo apt install -y  libemail-outlook-message-perl
    
    cd /tmp
    
    msgconvert test\ with\ html\ content.msg # creates  test\ with\ html\ content.eml
    
    Run Code Online (Sandbox Code Playgroud)
  • 使用https://github.com/nodemailer/mailparser从 eml 中获取信息,例如:

    git clone https://github.com/nodemailer/mailparser.git
    
    npm install
    
    cd mailparser/examples
    
    node extractInfoFromEml.js /tmp/test\ with\ html\ content.eml
    
    Run Code Online (Sandbox Code Playgroud)
  • 下面是 extractInfoFromEml.js 的代码(只是 simple.js 但接受一个参数。

    '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);
    
        });
    
    Run Code Online (Sandbox Code Playgroud)

    PS:显然 nodemailer 只接受错误,因此我无法在 github 中要求功能请求。