Skip to content

Commit

Permalink
add attributes to mail event
Browse files Browse the repository at this point in the history
  • Loading branch information
chirag04 committed May 2, 2014
1 parent dc016ca commit e69014d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e69014d

Please sign in to comment.