From e69014dd6162e3b2837e5aa7ef9244196c8ca7eb Mon Sep 17 00:00:00 2001 From: chirag Date: Fri, 2 May 2014 13:47:28 +0530 Subject: [PATCH] add attributes to mail event --- index.js | 7 ++++++- readme.md | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 3d2ba9f..0cd2658 100644 --- a/index.js +++ b/index.js @@ -75,12 +75,17 @@ function parseUnread() { }); f.on('message', function(msg, seqno) { var parser = new MailParser(self.mailParserOptions); + var attributes = null; + parser.on("end", function(mail) { - self.emit('mail', mail, seqno); + self.emit('mail', mail, seqno, attributes); }); msg.on('body', function(stream, info) { stream.pipe(parser); }); + msg.on('attributes', function(attrs) { + attributes = attrs; + }); }); f.once('error', function(err) { self.emit('error', err); diff --git a/readme.md b/readme.md index e33e23e..fd555af 100644 --- a/readme.md +++ b/readme.md @@ -51,7 +51,7 @@ mailListener.on("error", function(err){ console.log(err); }); -mailListener.on("mail", function(mail){ +mailListener.on("mail", function(mail, seqno, attributes){ // do something with mail object including attachments console.log("emailParsed", mail); // mail processing code goes here