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