Open anotheri opened 11 years ago
Do you want a callback when all the mails are parsed or when all the mails are fetched?
I might be able to send a PR for this as well.
@chirag04 when all the mails are fetched like here:
imap.fetch(results,
{ headers: ['from', 'to', 'subject', 'date'],
cb: function(fetch) {
fetch.on('message', function(msg) {
console.log('Saw message no. ' + msg.seqno);
msg.on('headers', function(hdrs) {
console.log('Headers for no. ' + msg.seqno + ': ' + show(hdrs));
});
msg.on('end', function() {
console.log('Finished message no. ' + msg.seqno);
});
});
}
},
function(err) {
if (err) throw err;
console.log('Done fetching all messages!');
imap.logout();
} // <—— THIS CALLBACK
);
Thank you.
Yes, I know about the callback that you asking about. But the thing is, mail-listener will call mailparser in the cb function which emits mail:parsed event. This mail:parsed event will be fired after the callback you asking for.
So, it comes down to, do you need callback for (done fetching all) or something like (done parsing all and emitting parsing event)
@chirag04 hm... seems I need second case (done parsing all and emitting parsing event).
@anotheri I think i will be able to do that for you by eod.
@chirag04 thank you very much
@chirag04 so... what's about it?
@anotheri sorry man! busy with other stuff. Will try to take some time out for this.
fetch(< mixed >source, [< object >options, ] < mixed >request, < function >callback) - (void) - Fetches message(s) in the currently open mailbox.
source
can be a message UID, a message UID range (e.g. '2504:2507' or '' or '2504:'), or an array of message UIDs and/or message UID rang ...callback
has 1 parameter: < Error >err. This is executed when all message retrievals are complete.There is usage examples here.
Please implement this feature in the options of mail-listener or emit some event from callback function.