I'm using the free lib ImapX and I'm making an application to mark all my mails as receieved. Can anyone lend me a hand?
EDIT: Nevermind, found it out myself. They get marked as read when you process them.
First of all, if you're using the old ImapX library, I invite you to upgrade to ImapX 2. It's being constantly developed and supported. There is also sample code for all common operations.
The Process
method of a message doesn't mark the message as read, it only downloads the whole message including attachments. In your case, if you call the Search
method setting the second parameter to true
, you don't have to call it for every single message.
To mark a message as read simply use the AddFlag
method of Message:
ImapX.FolderCollection folders = imapclient.Folders;
ImapX.MessageCollection messages = imapclient.Folders["INBOX"].Search("UNSEEN", true);
foreach (var mess in messages)
{
mess.AddFlag(ImapFlags.SEEN);
}
You need to add flag, which will help you to update status as seen.
Let me know if you are unable to change status.