gpt4 book ai didi

c# - 如何标记看不见的最后一条未读消息 S22.imap

转载 作者:行者123 更新时间:2023-12-04 00:39:45 25 4
gpt4 key购买 nike

如何从邮箱中读取最后一条未读消息并将此消息标记为“未读”

我用的是s22.imap.dll

ImapClient Client = new ImapClient("imap.gmail.com", 993, "My_Username",
"My_Password", true, AuthMethod.Login);

// Get a list of unique identifiers (UIDs) of all unread messages in the mailbox.
uint[] uids = Client.Search( SearchCondition.Unseen() );

// Fetch the messages and print out their subject lines.
foreach(uint uid in uids) {
MailMessage message = Client.GetMessage(uid);

Console.WriteLine(message.Subject);
}

// Free up any resources associated with this instance.
Client.Dispose();

最佳答案

先获取最后一条未读消息的uid:

var lastUid = Client.Search( SearchCondition.Unseen().Last() );

并阅读此消息;

MailMessage message = Client.GetMessage( lastUid );

要将此消息标记为“未看到”:

Client.RemoveMessageFlags( lastUid, null, MessageFlag.Seen );

查看更多信息:ImapClient.RemoveMessageFlags Method

关于c# - 如何标记看不见的最后一条未读消息 S22.imap,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20248399/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com