C# 使用EWS和Exchange 2007实现Outlook 2010的分组对话

C# 使用EWS和Exchange 2007实现Outlook 2010的分组对话,c#,outlook,exchange-server,exchangewebservices,exchange-server-2007,C#,Outlook,Exchange Server,Exchangewebservices,Exchange Server 2007,我们正在使用EWS对我们的一些邮箱进行分析 其中一部分是获取对话的计数/名称/开始/结束。对话类似于Outlook 2010按对话分组时显示的方式 我希望能够使用ConversationId对项目进行分组,但这似乎是Exchange 2010唯一的功能 我可以在文件夹中按主题分组,以获得线程的简单概念。。。然而,这并不能处理分割对话,就像Outlook 2010一样——具体地说,它不能处理发送的邮件中的回复——这些对我们很重要——如果不查看回复,我们就无法获得好的指标 我当前获取线程信息的代码如

我们正在使用EWS对我们的一些邮箱进行分析

其中一部分是获取对话的计数/名称/开始/结束。对话类似于Outlook 2010按对话分组时显示的方式

我希望能够使用ConversationId对项目进行分组,但这似乎是Exchange 2010唯一的功能

我可以在文件夹中按主题分组,以获得线程的简单概念。。。然而,这并不能处理分割对话,就像Outlook 2010一样——具体地说,它不能处理发送的邮件中的回复——这些对我们很重要——如果不查看回复,我们就无法获得好的指标

我当前获取线程信息的代码如下所示:

private IEnumerable<EmailThread> GetThreads(Folder folder)
    {
        var view = new ItemView(int.MaxValue) {PropertySet = new PropertySet(BasePropertySet.IdOnly)};

        // view.PropertySet.Add(ItemSchema.ConversationId); - Can't use this as we're stuck on Exchange 2007 !!!
        view.PropertySet.Add(ItemSchema.Subject);
        view.PropertySet.Add(ItemSchema.DateTimeReceived);

        var grouping = new Grouping(ItemSchema.Subject, SortDirection.Descending, ItemSchema.DateTimeReceived, AggregateType.Maximum);
        var groupResults = folder.FindItems(view, grouping);


        return groupResults.Select(x => new EmailThread
        {
            Name = x.Items.First().Subject,
            Items =  x.Items.Count,
            StartDate = x.Items.Last().DateTimeReceived, // Assume last in thread is first email
            EndDate = x.Items.First().DateTimeReceived // Assume first in thread is most recent
        });
    }

我希望有人知道一种简洁的方法,可以有效地获取构成对话一部分的回复信息。

您可以通过扩展属性获取ConversationId和ConversationIndex:

private static readonly ExtendedPropertyDefinition ConversationIdProperty = new ExtendedPropertyDefinition(0x3013, MapiPropertyType.Binary);
private static readonly ExtendedPropertyDefinition ConversationIndexProperty = new ExtendedPropertyDefinition(0x0071, MapiPropertyType.Binary);

var items = service.FindItems(WellKnownFolderName.Inbox, new ItemView(512) { PropertySet = new PropertySet(BasePropertySet.FirstClassProperties, 
            ConversationIdProperty, ConversationIndexProperty)});
两者都是二进制属性。此处详细介绍了其内容:

,第2.2.1.2节和第2.2.1.3节


属性本身在中定义。

谢谢,但我认为这没有任何用处,因为我在exchange 2007上。请参阅-具体而言,Exchange 2003、Exchange 2007、Office Outlook 2003和Office Outlook 2007不支持计算PidTagConversationId属性的值-如果不清楚的话,我要重申一点-我们有Exchange 2007和Outlook 2010,Outlook可以创建线程视图。。。假设不使用ConversationIdMark,您是对的。但您似乎可以派生PidTagConversationId值:尽管Exchange 2007不支持ConversationTopic属性,但它与PidTagNormalizedSubject值具有相同的值,请参见MS-OXOMSG 2.2.1.5。第2.2.1.2节规定了如何从该属性中删除ConversationId。ConversationIndex由Exchange2007支持;所以,通过这种组合,你应该能够解决这个问题。谢谢。。。了解ConversationTopic很有用,这将帮助我理解线程中的消息。当我请求PidTagConversationId时,它返回null,这很奇怪,因为它已经获得了PidTagConversationTopic,因此,给定2.2.1.2,应该返回该主题的MD5哈希值-我想这是留给我做的: