How to mark unseen last unread message S22.imap

随声附和 提交于 2020-01-04 17:21:08

问题


How read last unread message from mail box and after mark this message "Unseen"

I use 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();

回答1:


First get uid last unread message:

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

and read this message;

MailMessage message = Client.GetMessage( lastUid );

To mark this message as "Unseen":

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

See more on: ImapClient.RemoveMessageFlags Method



来源:https://stackoverflow.com/questions/20248399/how-to-mark-unseen-last-unread-message-s22-imap

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!