簡體   English   中英

如何標記看不見的上一條未讀消息S22.imap

[英]How to mark unseen last unread message S22.imap

如何從郵箱中讀取最后一條未讀郵件,並在標記此郵件后顯示“未看到”

我使用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方法

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM