使用 EWS 和 Exchange 2007 通过对话实现 Outlook 2010 的组 [英] Implementing Outlook 2010's group by conversation using EWS and Exchange 2007
问题描述
我们正在使用 EWS 对我们的一些邮箱生成一些分析.
We're using EWS to generate some analytics on some of our mailboxes.
其中一部分是获取对话的计数/名称/开始/结束.对话类似于 Outlook 2010 按对话分组时显示它们的方式.
Part of this is getting a count/name/start/end of conversations. A conversation being analogous to the way Outlook 2010 shows them when grouping by conversation.
我希望能够使用 ConversationId 对项目进行分组,但这似乎是 Exchange 2010 独有的功能.
I was hoping to be able to use the ConversationId to group items, but that seems to be an Exchange 2010-only feature.
我可以在文件夹中按主题分组以获得线程的简单概念...但是这不会处理拆分对话,就像 Outlook 2010 那样 - 具体来说,它不处理引入已发送的回复项目(这些对我们很重要 - 如果不查看回复,我们就无法获得好的指标).
I can group by subject within a folder to get a simple idea of threads... however this does not handle split conversations, as Outlook 2010 does - specifically, it doesn't handle bringing in the replies that are in the sent items (these are important to us - we can't get good metrics without also looking at replies).
我当前获取线程信息的代码如下所示:
My current code for getting thread info looks like this:
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
});
}
我希望有人知道一种巧妙的方法来有效地获取有关构成对话一部分的回复的信息?
I am hoping someone knows of a neat way to efficiently get information on replies that constitute part of a conversation?
推荐答案
您可以通过扩展属性获取 ConversationId 和 ConversationIndex:
You can fetch the ConversationId and the ConversationIndex via extended properties:
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)});
两者都是二元属性.此处详细描述了它们的内容:
Both are binary properties. Their content is described in great detail here:
[MS-OXOMSG]:E-邮件对象协议规范,第 2.2.1.2 和 2.2.1.3 节.
[MS-OXOMSG]: E-Mail Object Protocol Specification, section 2.2.1.2 and 2.2.1.3.
属性本身在 [MS-OXPROPS]:Exchange 服务器协议主属性列表.
这篇关于使用 EWS 和 Exchange 2007 通过对话实现 Outlook 2010 的组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!