Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I mark a message as read in MailKit

Tags:

c#

mailkit

I use MailKit to read some messages from a GMail Account. Works great, but when my application has read a message, I want to mark the message as read, and save that state to GMail. Is this possible with MailKit? I have not found anything about it yet.

like image 576
René Pjengaard Avatar asked Aug 13 '15 09:08

René Pjengaard


1 Answers

The way to mark messages as read using the IMAP protocol is to set the \Seen flag on the message(s).

To do this using MailKit, you will first need to know either the index(es) or the UID(s) of the messages that you would like to set the \Seen flag on. Once you have that information, you will want to call one of the AddFlags() methods on the ImapFolder. For example:

folder.AddFlags (uids, MessageFlags.Seen, true);

To mark messages as unread, you would remove the \Seen flag, like so:

folder.RemoveFlags (uids, MessageFlags.Seen, true);
like image 107
jstedfast Avatar answered Nov 09 '22 21:11

jstedfast