How can I mark a message as read in MailKit

后端 未结 1 1354
既然无缘
既然无缘 2021-01-07 17:12

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

相关标签:
1条回答
  • 2021-01-07 17:59

    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);
    
    0 讨论(0)
提交回复
热议问题