【问题标题】:Implementing Outlook 2010's group by conversation using EWS and Exchange 2007使用 EWS 和 Exchange 2007 通过对话实现 Outlook 2010 的组
【发布时间】:2011-11-21 04:50:15
【问题描述】:

我们正在使用 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
        });
    }

我希望有人知道一种巧妙的方法来有效地获取有关构成对话一部分的回复的信息?

【问题讨论】:

    标签: c# outlook exchange-server exchangewebservices exchange-server-2007


    【解决方案1】:

    您可以通过扩展属性获取 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)});
    

    两者都是二进制属性。他们的内容在这里有非常详细的描述:

    [MS-OXOMSG]: E-Mail Object Protocol Specification,第 2.2.1.2 和 2.2.1.3 节。

    属性本身在[MS-OXPROPS]: Exchange Server Protocols Master Property List中定义。

    【讨论】:

    • 谢谢,但我认为这对我在 Exchange 2007 上没有任何用处。请参阅here - 特别是“Exchange 2003 不支持 PidTagConversationId 属性值的计算, Exchange 2007、Office Outlook 2003 和 Office Outlook 2007" - 如果不清楚,我会重申 - 我们有带有 Outlook 2010 的 Exchange 2007,并且(不知何故)Outlook 能够创建线程视图......大概不使用 ConversationId跨度>
    • 马克,你是对的。但似乎您可以派生 PidTagConversationId 值:虽然 Exchange 2007 不支持 ConversationTopic 属性,但它与 PidTagNormalizedSubject 值具有相同的值(请参阅 MS-OXOMSG 2.2.1.5)。第 2.2.1.2 节指定如何从该属性派生 ConversationId。 Exchange 2007 支持 ConversationIndex;所以,有了这个组合,你应该能够解决问题。
    • 谢谢...了解 ConversationTopic 很有用,它将帮助我处理线程中的消息。当我询问 PidTagConversationId 时,它返回 null,这很奇怪,因为它已经获得了 PidTagConversationTopic,所以,给定 2.2.1.2,应该返回它的 MD5 哈希 - 我想这是留给我做的 :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-04-23
    • 2011-11-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-07
    相关资源
    最近更新 更多