是否有任何纯开源解决方案可以直接从 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 …Run Code Online (Sandbox Code Playgroud)