简体   繁体   English

如何在 MailKit 中将邮件标记为已读

[英]How can I mark a message as read in MailKit

I use MailKit to read some messages from a GMail Account.我使用 MailKit 从 GMail 帐户读取一些邮件。 Works great, but when my application has read a message, I want to mark the message as read, and save that state to GMail.效果很好,但是当我的应用程序阅读了一封邮件时,我想将该邮件标记为已读,并将该状态保存到 GMail。 Is this possible with MailKit?这可以用 MailKit 实现吗? I have not found anything about it yet.我还没有找到任何关于它的信息。

Best regards René最好的问候勒内

The way to mark messages as read using the IMAP protocol is to set the \\Seen flag on the message(s).使用 IMAP 协议将消息标记为已读的方法是在消息上设置\\Seen标志。

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.要使用 MailKit 执行此操作,您首先需要知道要设置\\Seen标志的邮件的索引或 UID。 Once you have that information, you will want to call one of the AddFlags() methods on the ImapFolder .获得该信息后,您将需要调用AddFlags()上的AddFlags()方法ImapFolder For example:例如:

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

To mark messages as unread, you would remove the \\Seen flag, like so:要将消息标记为未读,您可以删除\\Seen标志,如下所示:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM