如何从邮箱中读取上次未读邮件,并在将此邮件标记为“未显示”
之后我使用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();
答案 0 :(得分:3)
首先获取uid最后一条未读消息:
var lastUid = Client.Search( SearchCondition.Unseen().Last() );
并阅读此消息;
MailMessage message = Client.GetMessage( lastUid );
将此讯息标记为“看不见”:
Client.RemoveMessageFlags( lastUid, null, MessageFlag.Seen );