This project is read-only.

How to mark mail read and next time read only unread emails

Feb 10, 2016 at 2:21 PM

I am reading mails using Imap4Client as follows
int mailboxCount = imap.Mailboxes.Count;
            Mailbox myMailbox = imap.SelectMailbox("Inbox");
            int messageCount = myMailbox.MessageCount;
            for (int msgCount = 1; msgCount <= messageCount;msgCount++ )
                ActiveUp.Net.Mail.Message message = myMailbox.Fetch.MessageObject(msgCount);
                string msgId = message.MessageId;
Instead of reading all the mails again I want to read the unread mail only. Once mail info is downloaded then I want to mark that mail as read. Could anyone please help me in this regard.
Feb 12, 2016 at 12:44 AM
If you switch to MailKit instead, you can accomplish your goal like this:
client.Inbox.Open (FolderAccess.ReadWrite);
foreach (var uid in client.Inbox.Search (SearchQuery.NotSeen)) {
    var message = client.Inbox.GetMessage (uid);
    client.Inbox.AddFlags (uid, MessageFlags.Seen);
I think you'll find that MailKit is a much more robust and featureful IMAP library and I'm always available to answer questions.

MailSystem.NET, on the other hand, has been unmaintained for several years and questions never seem to get answered by anyone except me.

Hope that helps.