MailKit flag downloaded emails as seen

Viewed 7

Good morning everyone.

downloading an email from a server works like a charm. I setup the code to download only emails that don't have a flag seen. And emails are downloaded without any issues.

After I download the email I need to flag it. I tried this:

        using (var client = new ImapClient ()) {
        client.Connect ("xxx", 993, SecureSocketOptions.SslOnConnect);

        client.Authenticate ("yyy", "zzz");

        client.Inbox.Open (FolderAccess.ReadOnly);

        var uids = client.Inbox.Search (SearchQuery.NotSeen);
        //MessageBox.Show(uids[0].ToString());

        foreach (var uid in uids) {
        var message = client.Inbox.GetMessage (uid);

        // write the message to a file
        message.WriteTo (string.Format ("{0}.eml", uid));
        client.Inbox.SetFlags(uid, MessageFlags.Seen, true);
        }

        client.Disconnect (true);

"client.Inbox.SetFlags(uid, MessageFlags.Seen, true);"

did I use this correctly? Because it is not marking the downloaded messages. And if i check emails in inbox, they are still as not seen.

Thank you in advance!

0 Answers
Related