none
How can I compare Conversation Id from Exchange Web Services with Outlook Conversation Id ? RRS feed

  • Question

  • Hi Oulook 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=

    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 identifiers, so I know that this is the same thread ?

    Best regards

    David Nykjaer, 2ndC

    Monday, December 12, 2011 12:18 PM

Answers

  • Once you get a string value from ConversationID you just use string comparison functions. ConversationID isn't like EntryID, where you can have short and long-term id's that must be compared with a method such as NameSpace.CompareEntryIDs().
     
    However, that EWS result doesn't look at all like the ConversationID. Are you sure you're getting the same property and converting it correctly? Did you check in the EWS forum I directed you to in order to make sure you are getting the correct property and converting it correctly?

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "David Nykjær" <=?utf-8?B?RGF2aWQgTnlrasOmcg==?=> wrote in message news:9a7f8ad5-b5d5-44c9-a26c-ab51a429ad42...

    Hi Ken

     

    Decoding the EWS id gives us a guid: $22e3e3e5-8bb0-4ed2-8ced-3e90052606c7 (we used a wrong decoder)

    Do you know how we can compare this Conversation Id, to the outlook conversation id ? (CE407CAD6A9348B39DB2DC253D0429A4)

     

    Best regards

    David Nykjaer, 2ndC


    David Nykjaer, 2ndC

    Ken Slovak MVP - Outlook
    • Marked as answer by David Nykjær Thursday, December 15, 2011 1:16 PM
    • Unmarked as answer by David Nykjær Thursday, December 15, 2011 1:16 PM
    • Marked as answer by David Nykjær Friday, December 23, 2011 9:22 AM
    Wednesday, December 14, 2011 2:55 PM
    Moderator
  • Hi David,

    You can calculate the ConversationID from the email subject:

    oMailItem = DirectCast(Me.OutlookItem, MailItem)
    txtConvID.Text = oMailItem.ConversationID
    txtConvIndex.Text = oMailItem.ConversationIndex
    txtConvTopic.Text = oMailItem.ConversationTopic
    Dim strTmp As String = oMailItem.Subject.ToUpper
    strTmp = strTmp.Replace("RE: ", "")
    strTmp = strTmp.Replace("FW: ", "")
    strTmp = strTmp.Replace("FWD: ", "")
    If strTmp.Length > 265 Then strTmp = strTmp.Substring(0, 256)
    Dim Md5 As New System.Security.Cryptography.MD5CryptoServiceProvider
    Dim oByt As Byte() = Md5.ComputeHash(Encoding.Unicode.GetBytes(strTmp))
    Dim G As New Guid(oByt)
    strTmp = G.ToString.Replace("-", "").ToUpper
    strTmp = strTmp.Substring(6, 2) + strTmp.Substring(4, 2) + strTmp.Substring(2, 2) + strTmp.Substring(0, 2) + strTmp.Substring(10, 2) + strTmp.Substring(8, 2) + strTmp.Substring(14, 2) + strTmp.Substring(12, 2) + strTmp.Substring(16, 16)
    TextBox1.Text = strTmp

    • Proposed as answer by ECMBen Tuesday, April 10, 2012 5:28 PM
    • Marked as answer by David Nykjær Tuesday, May 1, 2012 6:53 AM
    Tuesday, April 10, 2012 5:28 PM

All replies

  • In the Outlook object model the PT_BINARY MAPI ConversationIndex property is converted for you by Outlook from a binary array of hex coded binary bytes into a string value.
     
    That EWS property looks to be Base64 encoded. Do the properties match if you were to decode the EWS string from Base64?
     
    Are you sure that you're reading an equivalent property from EWS? I haven't done a lot of EWS work, but I do recall that I had to use a non-intuitive looking property to get the EntryID and use it from EWS.
     
    There might be more expertise in this in a forum that specializes in EWS, you can try http://social.technet.microsoft.com/Forums/en-US/exchangesvrdevelopment/threads and see if anyone there has dealt with this sort of thing.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "David Nykjær" <=?utf-8?B?RGF2aWQgTnlrasOmcg==?=> wrote in message news:5551df43-d833-4352-b27a-70e18ef71576...

    Hi Oulook 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=

    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 identifiers, so I know that this is the same thread ?

    Best regards

    David Nykjaer, 2ndC


    Ken Slovak MVP - Outlook
    Monday, December 12, 2011 3:08 PM
    Moderator
  • Hi Ken

    Thanks for your answer. We are currently investigating your sugestions. I will get back.

    Best regards

    David


    David Nykjaer, 2ndC
    Tuesday, December 13, 2011 11:52 AM
  • Hi Ken

     

    Decoding the EWS id gives us a guid: $22e3e3e5-8bb0-4ed2-8ced-3e90052606c7 (we used a wrong decoder)

    Do you know how we can compare this Conversation Id, to the outlook conversation id ? (CE407CAD6A9348B39DB2DC253D0429A4)

     

    Best regards

    David Nykjaer, 2ndC


    David Nykjaer, 2ndC
    Wednesday, December 14, 2011 9:44 AM
  • Once you get a string value from ConversationID you just use string comparison functions. ConversationID isn't like EntryID, where you can have short and long-term id's that must be compared with a method such as NameSpace.CompareEntryIDs().
     
    However, that EWS result doesn't look at all like the ConversationID. Are you sure you're getting the same property and converting it correctly? Did you check in the EWS forum I directed you to in order to make sure you are getting the correct property and converting it correctly?

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "David Nykjær" <=?utf-8?B?RGF2aWQgTnlrasOmcg==?=> wrote in message news:9a7f8ad5-b5d5-44c9-a26c-ab51a429ad42...

    Hi Ken

     

    Decoding the EWS id gives us a guid: $22e3e3e5-8bb0-4ed2-8ced-3e90052606c7 (we used a wrong decoder)

    Do you know how we can compare this Conversation Id, to the outlook conversation id ? (CE407CAD6A9348B39DB2DC253D0429A4)

     

    Best regards

    David Nykjaer, 2ndC


    David Nykjaer, 2ndC

    Ken Slovak MVP - Outlook
    • Marked as answer by David Nykjær Thursday, December 15, 2011 1:16 PM
    • Unmarked as answer by David Nykjær Thursday, December 15, 2011 1:16 PM
    • Marked as answer by David Nykjær Friday, December 23, 2011 9:22 AM
    Wednesday, December 14, 2011 2:55 PM
    Moderator
  • Hi Ken

    Thanks again. I have cross posted in the Exchange Forum. Link is here: http://social.technet.microsoft.com/Forums/en-US/exchangesvrdevelopment/thread/6f7958ba-df0e-4bc9-a08f-5def3f2b233f

    When I get an answer, I will post it here.

    Best regards

    David Nykjaer, 2ndC


    David Nykjaer, 2ndC
    Thursday, December 15, 2011 1:18 PM
  • Hi Ken

    We have fixed the problem.

    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)

    Thank you very much for your help on this. I'll cross-post this answer in the Exchange forum.

    Best regards and happy holidays :-)

    David


    David Nykjaer, 2ndC
    • Proposed as answer by ECMBen Tuesday, April 10, 2012 5:27 PM
    • Unproposed as answer by ECMBen Tuesday, April 10, 2012 5:27 PM
    Friday, December 23, 2011 9:22 AM
  • Hi David,

    You can calculate the ConversationID from the email subject:

    oMailItem = DirectCast(Me.OutlookItem, MailItem)
    txtConvID.Text = oMailItem.ConversationID
    txtConvIndex.Text = oMailItem.ConversationIndex
    txtConvTopic.Text = oMailItem.ConversationTopic
    Dim strTmp As String = oMailItem.Subject.ToUpper
    strTmp = strTmp.Replace("RE: ", "")
    strTmp = strTmp.Replace("FW: ", "")
    strTmp = strTmp.Replace("FWD: ", "")
    If strTmp.Length > 265 Then strTmp = strTmp.Substring(0, 256)
    Dim Md5 As New System.Security.Cryptography.MD5CryptoServiceProvider
    Dim oByt As Byte() = Md5.ComputeHash(Encoding.Unicode.GetBytes(strTmp))
    Dim G As New Guid(oByt)
    strTmp = G.ToString.Replace("-", "").ToUpper
    strTmp = strTmp.Substring(6, 2) + strTmp.Substring(4, 2) + strTmp.Substring(2, 2) + strTmp.Substring(0, 2) + strTmp.Substring(10, 2) + strTmp.Substring(8, 2) + strTmp.Substring(14, 2) + strTmp.Substring(12, 2) + strTmp.Substring(16, 16)
    TextBox1.Text = strTmp

    • Proposed as answer by ECMBen Tuesday, April 10, 2012 5:28 PM
    • Marked as answer by David Nykjær Tuesday, May 1, 2012 6:53 AM
    Tuesday, April 10, 2012 5:28 PM
  • Thank you for an updated answer! :-)

    Best regards

    David


    David Nykjaer, 2ndC

    Tuesday, May 1, 2012 6:52 AM