使用EWS和exchange2007实现Outlook 2010's组对话
本文关键字:对话 2010 EWS exchange2007 实现 Outlook 使用 | 更新日期: 2023-09-27 18:09:03
我们正在使用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)});
都是二进制属性。它们的内容在这里有详细的描述:
[MS-OXOMSG]:电子邮件对象协议规范,第2.2.1.2和2.2.1.3节。
属性本身定义在[MS-OXPROPS]: Exchange Server Protocols Master Property List.