There is a self written application (c#) in place communicating over EWS (Webservice) with Exchange. Each mail item retrieved from EWS has a base64 encoded string as mail identifier. The string is a concatenation of the GUID of the mailbox itself, some flags and other unknown stuff. As observed in the application log the last 48 bit seem to represent a serial number that is increased for each new mail, because the base64 representation did that as well.
This looks the following way
AAMkADY4NGZiNmNmL[....]DruR5FpCowxZfCWAAAqi1dWAAA=
AAMkADY4NGZiNmNmL[....]DruR5FpCowxZfCWAAAqi1dXAAA=
AAMkADY4NGZiNmNmL[....]DruR5FpCowxZfCWAAAqi1dZAAA=
AAMkADY4NGZiNmNmL[....]DruR5FpCowxZfCWAAAqi1dYAAA=
AAMkADY4NGZiNmNmL[....]DruR5FpCowxZfCWAAAqi1daAAA=
AAMkADY4NGZiNmNmL[....]DruR5FpCowxZfCWAAAqi1dbAAA=
AAMkADY4NGZiNmNmL[....]DruR5FpCowxZfCWAAAqi1ddAAA=
AAMkADY4NGZiNmNmL[....]DruR5FpCowxZfCWAAAqi1deAAA=
^^^^^^^^
My intention is to decode the base64 representation and interpret the bit section in such a way that I get exchange's internal message id. This is necessary to ease message tracking.
The problem I'm facing is that now matter in which way I try to interpret the bits I never get a value that is close to the internal message id.
Right now the internal message id in exchange is at 195XXXXXX, but the binary value interpreted as an long gives a value somewhere around 713XXXXXX what makes absolutely no sense.
To make matter worse I observed a break in the sequence:
AAAqi1kKAAA=
AAAqi1kLAAA=
AAAqi1kMAAA= (decimal 713775372)
AAAqjUbTAAA= (decimal 713901779)
AAAqjUbUAAA=
AAAqjUbVAAA=
That means that suddenly the serial number is increased by ~126'400
I can't imagine that exchange uses a different message id in EWS context than internally and is maintaining the mapping information somewhere.
Does anybody have an idea how to get the right message id?
I believe the EWS ConvertId operation or EWS Managed API ConvertId method is what you want to use to do the conversion. There's more information here: Converting identifiers.