node-imap icon indicating copy to clipboard operation
node-imap copied to clipboard

Search using ['UID', next_message_id + ':*'] Always returns the last mailbox message

Open RedTint opened this issue 11 years ago • 4 comments

Example: I have a message with UID = 28.

Problem: Running ``imap.search([['UID', '1000:*']], function(err, results) {}) always returns the last message in the mailbox.

I'm storing the last UID of the mailbox processed. I just want to process the next ones after that.

Thanks!

RedTint avatar May 22 '15 14:05 RedTint

Is 1000 the second to last message in the mailbox or ?

mscdex avatar May 22 '15 15:05 mscdex

That's actually way far beyond it already. I had it exaggerated to test whether the bug is really there.

In reality, I actually have UID 27 as the last_message_id but using ['UID', '28:*'] and even ['UID', '1000:*'] seems to still return the last message.

RedTint avatar May 22 '15 15:05 RedTint

Ok in that case, this is expected behavior. Quoted from RFC 3501:

      Also note that a UID range of 559:* always includes the
      UID of the last message in the mailbox, even if 559 is
      higher than any assigned UID value.  This is because the
      contents of a range are independent of the order of the
      range endpoints.  Thus, any UID range with * as one of
      the endpoints indicates at least one message (the
      message with the highest numbered UID), unless the
      mailbox is empty.

So if you end up getting just one UID back, you'll just have to compare that against the last message UID you have stored.

mscdex avatar May 22 '15 15:05 mscdex

Good idea. Thanks :+1:

RedTint avatar May 22 '15 15:05 RedTint