smiley22 / S22.Imap

A free, easy-to-use and well-documented .NET library component for communicating with IMAP servers
http://smiley22.github.com/S22.Imap/Documentation/
MIT License
211 stars 115 forks source link

Retrieving mail ids from a folder #141

Open kesopeso opened 6 years ago

kesopeso commented 6 years ago

Hi,

when i retrieve mail ids from the "inbox" folder with this code _imap.Search(SearchCondition.All(), "inbox"); everything works as expected. So far so good.

After I process some emails, I move them to my archive folder, which is a subfolder in inbox (inbox/myarchive). Then I do the _imap.Search(SearchCondition.All(), "inbox"); call again. I still get the email ids that I just moved to my archive folder as a result of that function call. Am I doing something wrong? Should I somehow make the Imap class refresh the state or something? Or is it just a bug?

mmoo9154 commented 5 years ago

@kesopeso, you should post your code for "moving" your messages to a subfolder.

According to the IMAP specification, a message never changes its UID number. If you deleted the messages from the inbox folder when you "moved" them, that really just sets the /Deleted flag on the message. You will still find the UID in the Search results.

If you deleted the messages, and then you call the _imap.Expunge(mailbox) method, the server will remove the messages marked /Deleted, and then '_imap.Search()` will not return the deleted UID's.

The short answer to your question is "No", it's not a bug. And, "No", you do not have to refresh any state. ImapClient will issue a command to the IMAP server everytime you call _imap.Search(). You can trust the result you get back (or don't get back) is the actual response from the IMAP server.