Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Callback when all message retrievals are complete #19

Open
anotheri opened this issue May 23, 2013 · 8 comments
Open

Callback when all message retrievals are complete #19

anotheri opened this issue May 23, 2013 · 8 comments

Comments

@anotheri
Copy link

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.

@chirag04
Copy link
Contributor

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.

@anotheri
Copy link
Author

@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.

@chirag04
Copy link
Contributor

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)

@anotheri
Copy link
Author

@chirag04
hm... seems I need second case (done parsing all and emitting parsing event).

@chirag04
Copy link
Contributor

@anotheri I think i will be able to do that for you by eod.

@anotheri
Copy link
Author

@chirag04 thank you very much

@anotheri
Copy link
Author

@chirag04 so... what's about it?

@chirag04
Copy link
Contributor

@anotheri sorry man! busy with other stuff. Will try to take some time out for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants