如果您的服务器支持该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
,那么这些将是回复。