none
[E2010] [EWS] [C#]: How do I compare an Exchange Conversation Id to an Outlook Conversation Id RRS feed

  • Question

  • Hi Forum

    I have sended an e-mail to "XX" using Exchange Web Service, and retrieved the Conversation Id using Exchange Web Services on the sent mail.
    In EWS, the id looks like this: AAQkADIyZTNlM2U1LThiYjAtNGVkMi04Y2VkLTNlOTAwNTI2MDZjNwAQAM5AfK1qk0iznbLcJT0EKaQ=
    This is base64 encoded and decodes to a guid: $22e3e3e5-8bb0-4ed2-8ced-3e90052606c7

    In Outlook, the user "XX" finds the received e-mail, and using Outlook .Net API (Vsto40 add in), looks up the Conversation Id.
    In Outlook API, the id looks like this: CE407CAD6A9348B39DB2DC253D0429A4

    How can I match the two conversation ids, so I know that this is the same thread ?

    Best regards

    David Nykjaer, 2ndC

    (I have posted a similair question i the Outlook API Forum, and was asked to post here in this Exchange forum (see http://social.msdn.microsoft.com/Forums/en-US/outlookdev/thread/5551df43-d833-4352-b27a-70e18ef71576))

     

     


    David Nykjaer, 2ndC
    Thursday, December 15, 2011 1:15 PM

Answers

  • The ConversationID EWS returns is in its own ItemID format and is meant for searching and the other conversation operations EWS has in 2010 which are documented in http://msdn.microsoft.com/en-us/library/ff631254%28v=EXCHG.80%29.aspx AFAIK currently EWS doesn't allow you to convert it to a HexEntryID etc . I would suggest you just use the Extended Mapi property directly instead which will match what you can get with Outlook eg

                ExtendedPropertyDefinition PR_CONVERSATION_INDEX = new ExtendedPropertyDefinition(0x0071, MapiPropertyType.Binary);
                PropertySet psPropSet = new PropertySet(BasePropertySet.FirstClassProperties) { PR_CONVERSATION_INDEX };
                email.Load(psPropSet);
                Object cnvId = null;
                if (email.TryGetProperty(PR_CONVERSATION_INDEX, out cnvId)) {
                    String Output = BitConverter.ToString((Byte[])cnvId);
                    Console.WriteLine(Output.Replace("-",""));
                }
    


    Cheers
    Glen

    • Marked as answer by David Nykjær Friday, December 23, 2011 9:24 AM
    Friday, December 16, 2011 2:49 AM

All replies

  • The ConversationID EWS returns is in its own ItemID format and is meant for searching and the other conversation operations EWS has in 2010 which are documented in http://msdn.microsoft.com/en-us/library/ff631254%28v=EXCHG.80%29.aspx AFAIK currently EWS doesn't allow you to convert it to a HexEntryID etc . I would suggest you just use the Extended Mapi property directly instead which will match what you can get with Outlook eg

                ExtendedPropertyDefinition PR_CONVERSATION_INDEX = new ExtendedPropertyDefinition(0x0071, MapiPropertyType.Binary);
                PropertySet psPropSet = new PropertySet(BasePropertySet.FirstClassProperties) { PR_CONVERSATION_INDEX };
                email.Load(psPropSet);
                Object cnvId = null;
                if (email.TryGetProperty(PR_CONVERSATION_INDEX, out cnvId)) {
                    String Output = BitConverter.ToString((Byte[])cnvId);
                    Console.WriteLine(Output.Replace("-",""));
                }
    


    Cheers
    Glen

    • Marked as answer by David Nykjær Friday, December 23, 2011 9:24 AM
    Friday, December 16, 2011 2:49 AM
  • Hi Glen

    This solves the problem. Thank you very much. I have also updated the Outlook forum post.

    (Our solution to the problem was to use the MAPI property in EWS (PR_CONVERSATION_ID, 0x3013) in stead of the Managed API (EWS) property related to the item object. The MAPI property in EWS returns the same value as in the Outlook Managed API (and we could also set the MAPI property for new e-mails in order to make them apear in the same thread in Outlook))

    Best regards and happy holidays :-)

    David


    David Nykjaer, 2ndC
    Friday, December 23, 2011 9:24 AM
  • Hi All,

    In 2019 : I am developing a COM Addin and ran into this exact same problem. I am pretty new to .Net and com addins and hope there was a easy COM2GraphConversationId function to use.

    From above Outlook.MailItem does not have a 

      email.Load(psPropSet);

    Niether there is any 

    .TryGetProperty(PR_CONVERSATION_INDEX, out cnvId)

    Can someone please help me with the solutions for this.

    Also put up here : https://stackoverflow.com/questions/55530541/mailitem-conversationid-not-same-as-graph-apis-conversationid

    Thanks,

    -Jatin



    • Edited by JatinC Monday, October 7, 2019 9:32 AM
    Monday, October 7, 2019 9:32 AM
  • If your writing a Com plugin why use the Graph? (in 2019 writing a Com plugin probably isn't the best strategy)  you could just use the OOM to search for messages which would be more efficient.

    Cheers
    Glen

     
    Tuesday, October 8, 2019 8:04 AM
  • Thanks Glen.

    We need to have a COM Addin to offer something WebAddins cannot.

    On why we need it .. Our backend only understands the GraphAPI (we store the ConversationId there) and hence we need the conversion. Else there is an additional hop for our BE to get it from something like InternetMessageId.


    Tuesday, October 8, 2019 8:57 AM
  • Instead of storing the Graph ConversationId you maybe better just requesting the Extended property from graph to get the corresponding Outlook ConversationId eg

    https://graph.microsoft.com/v1.0/me/messages?$select=Subject&$Top=10&$expand=SingleValueExtendedProperties($filter=(Id%20eq%20'Binary%200x3013'))

    You could filter on that property as well in the Graph

    Cheers
    Glen


    Tuesday, October 8, 2019 11:59 PM