[This is now documented here: http://msdn2.microsoft.com/en-us/library/bb820967.aspx]
We had some folks asking recently if there's a property in the profile you can use to determine what version of Exchange the mailbox in the profile is on. It turns out there is, but it's not guaranteed to be there, and it changes in Outlook 2007.
First, the pre-Outlook 2007 property: The version of emsmdb32.dll that comes with Outlook 2003 and earlier and with all of Exchange's implementations of MAPI will write the property PR_PROFILE_SERVER_VERSION into the global profile section of the profile. This property was previously discussed in Jason's blog posting on GC Reconnect. This property is a PT_LONG, and will typically contain partial information about the build of the Exchange server. However, the data contained in this property is not encoded consistently between different versions of Exchange.
For instance, against my test Exchange 2003 server, I see this property contains 6944 decimal - the version of store.exe on this server is 6.5.6944.3. Against my test Exchange 2007 server, I see the property contains 33453 decimal, which is 0x82AD hex. 0x2AD hex is 685 decimal. The version of store on my test Exchange 2007 server is 8.0.685.24, so we see the major version and build numbers were encoded in the property.
The developers of Outlook 2007 wanted more granularity out of the version. The conversation emsmdb32 conducts with the Exchange server actually contains the full version information. But that's too much to stick in a PT_LONG. So they created a new property, PR_PROFILE_SERVER_FULL_VERSION, which is a PT_BINARY. This allows us to store a EXCHANGE_STORE_VERSION_NUM structure with both the major and minor version numbers and the major and minor build numbers (note: this is the same format used by PR_REPLICA_VERSION). When we look at an Outlook 2007 profile connecting to the above servers, we see the full version information is available.
Here's a function I wrote to demonstrate how to fetch these properties:
#define PR_PROFILE_SERVER_VERSION PROP_TAG( PT_LONG, 0x661B)
#define PR_PROFILE_SERVER_FULL_VERSION PROP_TAG( PT_BINARY, 0x663B)
HRESULT GetProfileServiceVersion(LPSTR lpszProfileName,
|| !lpbFoundServerFullVersion) return MAPI_E_INVALID_PARAMETER;
*lpbFoundServerVersion = false;
*lpbFoundServerFullVersion = false;
HRESULT hRes= S_OK;
LPPROFADMIN lpProfAdmin = NULL;
LPSERVICEADMIN lpServiceAdmin = NULL;
hRes = MAPIAdminProfiles(0, &lpProfAdmin);
if (!lpProfAdmin) return hRes;
hRes = lpProfAdmin->AdminServices(
LPPROFSECT lpProfSect = NULL;
hRes = lpServiceAdmin->OpenProfileSection(
LPSPropValue lpServerVersion = NULL;
hRes = HrGetOneProp(lpProfSect,PR_PROFILE_SERVER_VERSION,&lpServerVersion);
if (SUCCEEDED(hRes) && lpServerVersion && PR_PROFILE_SERVER_VERSION == lpServerVersion->ulPropTag)
*lpbFoundServerVersion = true;
*lpulServerVersion = lpServerVersion->Value.l;
LPSPropValue lpServerFullVersion = NULL;
hRes = HrGetOneProp(lpProfSect,PR_PROFILE_SERVER_FULL_VERSION,&lpServerFullVersion);
if (SUCCEEDED(hRes) &&
PR_PROFILE_SERVER_FULL_VERSION == lpServerFullVersion->ulPropTag)
if (lpServerFullVersion->Value.bin.cb == sizeof(EXCHANGE_STORE_VERSION_NUM))
EXCHANGE_STORE_VERSION_NUM* lpStoreVersion =
*lpbFoundServerFullVersion = true;
*lpwMajorVersion = lpStoreVersion->wMajorVersion;
*lpwMinorVersion = lpStoreVersion->wMinorVersion;
*lpwBuild = lpStoreVersion->wBuild;
*lpwMinorBuild = lpStoreVersion->wMinorBuild;
// If we found any server version, consider the call a success
if (*lpbFoundServerVersion || *lpbFoundServerFullVersion) hRes = S_OK;
I got the PR_PROFILE_SERVER_VERSION property, as described by you, for both Exchange 2003 and Exchange 2007 Servers.
For 2003 Server i got the version# as: 0x1DE4 (decimal 7652)
For 2007 Server i got the version# as: 0x82AD (decimal 33453)
Now, the other way around:
Given the numbers, how do i make out what what version of the server am i connecting to? Do i have to hard code these values and map them?
Apropos my last comment, i could not retrieve the PR_PROFILE_SERVER_FULL_VERSION property for either of the servers (got "MAPI_E_NOT_FOUND" error)
>Do i have to hard code these values and map them?
Pretty much - that's why I didn't include code for parsing them. :)
PR_PROFILE_SERVER_FULL_VERSION should only be in profiles created/used by Outlook 2007 - the server is irrelevent. Apologies if I didn't make that clear.
Thanks a lot Stephen, that was really helpful.
This is a great sample. Thanks! How does this function with Outlook 2010, where you can have multiple Exchange message stores in a profile? Which Exchange server version is stored in these properties? Or is this whole structure obsolete in Outlook 2010?
For multiex, pbGlobalProfileSectionGuid will open the profile section for the primary mailbox. For other mailboxes, you'll need to open the appropriate profile section (see multi-ex docs) then the property will give the version for that server.
You mention that PR_REPLICA_VERSION uses the same format.
This may be true up to Exchange 2007.
Looking at Exchange 2010 or 2013, I cannot map the property to a version number.
- for Version 15.0 (Build 775.38), I see hex F00000583070FB6 which would be version 3840.5.33543.4022
- for Version 15.0 (Build 847.32), I see hex 8030005815C0001 which would be version 2051.5.33116.1
- for 2010 SP3 RU 5 (according to programs/features - EMC and EMS show Version 14.3 (Build 123.4), I see hex E03000580B50FA6 which would be 3587.5.32949.4006
Can you shed some light?