none
EWS - retrieving PR_STORE_ENTRYID value RRS feed

  • Question

  • Hi,

    I am trying to retrieve PR_STORE_ENTRYID value on a mailbox.

    Here is the code snippet.

    var ourProps = new PropertySet(BasePropertySet.IdOnly);
                var PR_STORE_ENTRYID = new ExtendedPropertyDefinition(4091, MapiPropertyType.Binary);
                ourProps.Add(PR_STORE_ENTRYID);
     
                Folder rootFolder = Folder.Bind(service, WellKnownFolderName.Root, ourProps);
                                      object propVal = null;
     
                if (rootFolder.TryGetProperty(PR_STORE_ENTRYID, out propVal))
                {
    
                    // blablabalba
    
                }
    
    
    

    The byte array that EWS returns me is 124 bytes.

    Here is the converted string:

    0000000038A1BB1005E5101AA1BB08002B2A56C20000454D534D44422E444C4C00000000000000001B55FA20AA6611CD9BC800AA002FC45A0C0000006578323031332D62652D30312E6C61627A65726F2E6D316465762E636F6D0045DC3FDD3E452141997812ED19A12EF55926AE630700304EAD87CD5D218DE025

    While OutlookSpy and MfcMAPI show that PR_STORE_ENTRYID has 244 bytes.

    0000000038A1BB1005E5101AA1BB08002B2A56C20000454D534D44422E444C4C00000000000000001B55FA20AA6611CD9BC800AA002FC45A0C00000064643366646334352D343533652D343132312D393937382D313265643139613132656635406C61627A65726F2E6D316465762E636F6D002F6F3D456D734465764F7267616E697A6174696F6E2F6F753D45786368616E67652041646D696E6973747261746976652047726F7570202846594449424F484632335350444C54292F636E3D526563697069656E74732F636E3D62326531343437353635346534393331386562353136323037646238646439302D41646D696E00

    I am not sure why EWS returns different byte array value.

    Does anyone know why this is the case?

    Thanks.

    Tuesday, May 14, 2013 6:46 PM

Answers

All replies

    • Marked as answer by Blackfield Tuesday, May 14, 2013 7:09 PM
    Tuesday, May 14, 2013 6:54 PM
  • I didnt really understand that link. Did you find a solution for this?

    Its driving me nuts trying to convert the EWS Stored ID into Hex for use with the MAPI API ie GetFolderFromID(EntryID,StoreID);

    Tuesday, December 3, 2013 11:39 PM
  • If you want the StoreID your better to just to generate it yourself using Autodiscover using whats documented in http://msdn.microsoft.com/en-us/library/ee203516%28v=exchg.80%29.aspx

    eg for a Mailbox Store you can use

            static String GetStoreId(String emEmailAddress, ExchangeService service) {
                String rtReturnString = "";
                AutodiscoverService adAutoDiscoverService1 = new AutodiscoverService(ExchangeVersion.Exchange2010_SP2);
                adAutoDiscoverService1.Credentials = service.Credentials;
                adAutoDiscoverService1.EnableScpLookup = false;
                adAutoDiscoverService1.RedirectionUrlValidationCallback = adAutoDiscoCallBack;
                adAutoDiscoverService1.PreAuthenticate = true;
                adAutoDiscoverService1.KeepAlive = false;
                GetUserSettingsResponse adResponse = adAutoDiscoverService1.GetUserSettings(emEmailAddress, (new UserSettingName[2] { UserSettingName.UserDN, UserSettingName.InternalRpcClientServer }));
                if (adResponse.Settings.Count >= 2)
                {
                    String UserDN = (String)adResponse.Settings[UserSettingName.UserDN];
                    String ServerName = (String)adResponse.Settings[UserSettingName.InternalRpcClientServer];
                    String flags = "00000000";
                    String ProviderUID = "38A1BB1005E5101AA1BB08002B2A56C2";
                    String versionFlag = "0000";  
                    String DLLFileName = "454D534D44422E444C4C00000000";  
                    String WrappedFlags = "00000000";  
                    String WrappedProviderUID = "1B55FA20AA6611CD9BC800AA002FC45A";  
                    String WrappedType = "0C000000";
                    String StoredIdStringHex = flags + ProviderUID + versionFlag + DLLFileName + WrappedFlags + WrappedProviderUID + WrappedType + StringToHex(ServerName) + "00" + StringToHex(UserDN) + "00";
                    rtReturnString = StoredIdStringHex;
                }
                return rtReturnString;
            }
            static string StringToHex(string asciiString)
            {
                string hex = "";
                foreach (char c in asciiString)
                {
                    int tmp = c;
                    hex += String.Format("{0:x2}", (uint)System.Convert.ToUInt32(tmp.ToString()));
                }
                return hex;
            }

    For the Public Folder Store you just need to vary the WrappedProvider as documented.

    Cheers
    Glen

    Wednesday, December 4, 2013 4:37 AM