vb6exchange-servermapiexchange-server-2010exchange-server-2003

Exchange 2010 and root folders


On Exchange 2003 I can run the following code.

Using VB6 and MAPI CDO 1.2.1

Private Sub Command1_Click()
    Dim objSession As MAPI.Session
    Set objSession = CreateObject("MAPI.Session")
    strProfileInfo = myExcServer & vbLf & myExcAlias
    objSession.Logon ProfileInfo:=strProfileInfo
    For Each nfo In objSession.InfoStores
        Text1.Text = Text1.Text & "nfo.Name: " & nfo.Name & vbNewLine
        Text1.Text = Text1.Text & "nfo.RootFolder.Name: " & nfo.RootFolder.Name & vbNewLine
    Next
    Set objMessage = Nothing
    Set objInbox = Nothing
    objSession.Logoff
    Set objSession = Nothing
End Sub

I get:

nfo.Name: Public Folders
nfo.RootFolder.Name: IPM_SUBTREE
nfo.Name: Mailbox - pperez pperez
nfo.RootFolder.Name: Top of Information Store

However I'm trying to run it on Exchange 2010 but I'm getting an error,

nfo.Name: Public Folders
Run-time error '-2147221219 (8004011D)':
[Collaboration Data Objects - [MAPI_E_FAILONEPROVIDER(8004011D)]]

The exception is being thrown just in the reference to the root folder, nfo.RootFolder.Name.

Is this property not supported on 2010?

Any advice is welcome, Thanks.


Solution

  • Arw you sure your Exchange 2010 actually has the PF store? Try to access the default store first (e.g. read the Inbox folder name) before looping through the stores - that will cause CDO 1.21 to hit the server and realize that there is no PF store.