Chris
Chris

Reputation: 2374

read outlook msg files with node js

I'm trying to read msg-files that are exported from outlook.

Is there a way of reading the original recipient in the msg-file with nodejs? (I don't have online office365, I'm talking about files on disk).

As a rare exception, I couldn't find a npm module for this :-)

Thanks Christian

Upvotes: 4

Views: 4452

Answers (1)

bobcatBisto
bobcatBisto

Reputation: 56

I found this library to be very useful - https://www.npmjs.com/package/@kenjiuno/msgreader

Ideally, you'd be doing something like this:

import MsgReader from '@kenjiuno/msgreader';
import * as fs from 'fs'

readMail = () => { 
var readFileAsBuffer = fs.readFileSync('fileLocationHere');
var msgReader = new MSGReader(readFileAsBuffer );
var fileData = msgReader.getFileData();
//FileData will have body, subject etc
var getBody = fileData.body;
}

Upvotes: 3

Related Questions