【问题标题】:How to mark unseen last unread message S22.imap如何标记看不见的最后一条未读消息 S22.imap
【发布时间】:2014-02-20 19:11:12
【问题描述】:

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

我使用 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();

【问题讨论】:

    标签: c# imap


    【解决方案1】:

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

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

    并阅读此消息;

    MailMessage message = Client.GetMessage( lastUid );
    

    将此消息标记为“未见”:

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

    查看更多信息:ImapClient.RemoveMessageFlags Method

    【讨论】:

      猜你喜欢
      • 2010-12-08
      • 2023-01-21
      • 2014-09-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-07
      • 2011-08-27
      相关资源
      最近更新 更多