Search code examples
.netemailimapgmail-imap

AE.Net.Mail - IMAP UID tracking to get latest emails


I'm successfully using the AE.Net.Mail library to retrieve messages from an imap folder. I'm now trying to build out the portion that will let me check only for messages that I haven't already retrieved in the past. If I store the UID of the last message I retrieve (for a particular mailbox), I'm a bit confused how to use it to:

-Request any message newer than the UID

-Request a max of x messages (ie, 100)

the library requests that I send in a "start" and "end" uid, but I'd prefer to just send the "start" uid and then limit how many msgs will be returned, or be able to set nothing for the end UID in case I want to retrieve everything past the start.

Am I looking at this wrong?


Solution

  • IMAP allows you to send '*' as the end UID. Hopefully your library supports it.

    The raw command looks like: UID FETCH 739:* ([items])

    Unfortunately, there's no limit to the amount of messages that can be returned. If you want to do that, you need to specify an end number, or the complete sequence of messages you want.