Using CDO to Retrieve the StoreID

The CML/LitCrit application needs the identifier (storeID) of the Microsoft Exchange Server information store in order to open public folders in that information store. Then, the application can open a message in a public folder.

The following loop compares for inequality the name of the root of the public folder hierarchy ("Personal Folders") to the ProviderName property of the objStore object within the InfoStores collection of the top-level CDO Session object. When this test is true, the Public Folders root folder has been found.
For Each objStore In objCDOSession.InfoStores
     If objStore.ProviderName <> "Personal Folders" Then
          lMask = objStore.Fields.Item(&H340D0003)                  'PR_STORE_SUPPORT_MASK
          If  lMask And &H00004000 Then ' STORE_PUBLIC_FOLDERS
                StoreID = objStore.ID
                Exit For
          End If
      End If
  Next

objCDOSession.Logoff