Convert MSG to EML in CLI ?
Erwane opened this issue · comments
Hi, this is the best msg to eml convert i've found.
There is a possibility to run it in command line ?
Thanks
Should be possible to write a simple script in Node.js that calls the msg2eml function which can be called from command line.
excellent. I'm really noob with node. Do you have a quick example or page tutorial ?
Maybe something like this ?
- https://stackoverflow.com/questions/30782693/run-function-in-script-from-command-line-node-js
- https://www.digitalocean.com/community/tutorials/nodejs-command-line-arguments-node-scripts
Thanks
Don't have an example, otherwise you can look at the below Python script which most of my web version is based on:
Hi, There is a npm package or not for this repository ?
Here my CLI code
mkdir convert-msg
cd convert-msg
git clone https://github.com/master131/msg2eml.js.git msg2eml
cd msg2eml
npm install
npm run build
cd ..
Create a package.json
{
"name": "convert-msg",
"version": "1.0.0",
"description": "Convert Outlook .msg Files to .eml in CLI",
"main": "convert.js",
"bin": {
"convert-msg": "convert.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"filereader": "^0.10",
"file-api": "^0.10",
"mime": "^1"
}
}
Then
npm install --no-fund
Create a convert.js
let msg2eml = require('./msg2eml/lib/msg2eml');
const FileReader = require("filereader/FileReader");
const FileApi = require('file-api');
const args = process.argv.slice(2);
let filePath = args[0];
function convertMsgToEml(path) {
let file = new FileApi.File(path);
let fileReader = new FileReader();
fileReader.onload = function (e) {
let buffer = fileReader.result;
let arrayBuffer = Array.from(buffer);
msg2eml(arrayBuffer)
.then(function (eml) {
fileReader = null;
process.stdout.write(eml);
})
.catch(() => {
process.exit(1);
});
};
fileReader.readAsArrayBuffer(file);
}
convertMsgToEml(filePath);
then
node convert.js /path/to/msg >/path/to/eml
Improvements welcome :)