【问题标题】:How to get "RE:" reply thread in an email message如何在电子邮件中获取“RE:”回复线程
【发布时间】:2015-10-20 14:56:32
【问题描述】:

我正在使用“MailKit”从邮件服务器获取消息。

http://solvedstack.com/questions/using-c-net-librarires-to-check-for-imap-messages-from-gmail-servers-closed

我使用了文本下方的代码“我建议查看 MailKit,因为它可能是最强大的邮件库,而且它是开源 (MIT)。

MailKit 的一大优点是所有网络 API 都是可取消的(我在任何其他 IMAP 库中都没有看到可用的)。

它也是我所知道的唯一支持消息线程的库。”

现在上面代码的问题是我无法获取消息回复。我已经根据邮件主题搜索了邮件,但我只收到了第一条邮件,没有收到邮件中的其他回复。那么谁能告诉我如何在电子邮件中获得回复线程。

【问题讨论】:

    标签: c# mailkit


    【解决方案1】:

    如果您的服务器支持THREAD 扩展,您可能会想要使用它。

    以下是您可以使用的方法:

    if (client.Capabilities.HasFlag (ImapCapabilities.Thread)) {
        var threads = client.Inbox.Thread (ThreadingAlgorithm.References, SearchQuery.All);
    
        // `threads' now holds the relationship of all messages in the Inbox
        // so that you can figure out which messages are replies to what
        // other message. Each MessageThread node will have a UniqueId that
        // you can use to get the message at that node and a list of
        // "children" (which are replies to that message).
    }
    

    如果您的 IMAP 服务器不支持 THREAD 扩展,您可以改为这样做以获得相同的结果:

    var messages = client.Inbox.Fetch (0, -1, MessageSummaryItems.UniqueId |
        MessageSummaryItems.Envelope | MessageSummaryItems.References);
    var threads = MessageThreader.Thread (ThreadingAlgorithm.References, messages);
    

    如果您要查找对特定消息的回复,则需要知道该消息的 UniqueId,然后搜索 threads 结构以找到匹配的 UniqueId。如果该节点有任何Children,那么这些将是回复。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-10-09
      • 2012-02-09
      • 1970-01-01
      • 2014-01-27
      • 1970-01-01
      • 1970-01-01
      • 2020-06-05
      • 2017-06-29
      相关资源
      最近更新 更多