This project is read-only.

IMAP in concurrent sessions

Nov 4, 2013 at 12:08 PM

I'm trying to get all messages from a mailbox by iterating from 1 to mailbox.MessageCount and doing a mailbox.Fetch.MessageObject(i).
When during the loop a message is deleted in another session, the sequence number of all following messages on the server is decreased by 1.
So in the loop, it's possible that I'm missing messages. Example: Fetch(#1), Fetch(#2), (in another session) Delete(#1) -> when I do a Fetch(#3) now, one message is missing, because #3 is now #2.. And also in the end of the loop the index is out of range, because there is one less mail in the mailbox.
Any idea, what would be the best way to deal with this situation?

Nov 4, 2013 at 1:21 PM
I checked the behavior with a telnet connection. With the raw IMAP protocol the ordinal numers of messages seems not to change. When I try to fetch a deleted message the server says something like "OK [EXPUNGEISSUED] Some messages were already expunged.". In the Mailsystem.Net source within each fetch a implicite SelectMailbox(..) is executed. Looks like this invalidates the ordinal numbers ??