Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

We're using EWS to generate some analytics on some of our mailboxes.

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.

I was hoping to be able to use the ConversationId to group items, but that seems to be an Exchange 2010-only feature.

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
401 views
Welcome To Ask or Share your Answers For Others

1 Answer

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-Mail Object Protocol Specification, section 2.2.1.2 and 2.2.1.3.

The properties themselves are defined in [MS-OXPROPS]: Exchange Server Protocols Master Property List.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...