在 Exchange 2003 上,我可以运行以下代码。
使用 VB6 和 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
我得到:
nfo.Name: Public Folders
nfo.RootFolder.Name: IPM_SUBTREE
nfo.Name: Mailbox - pperez pperez
nfo.RootFolder.Name: Top of Information Store
但是,我尝试在 Exchange 2010 上运行它,但出现错误,
nfo.Name: Public Folders
Run-time error '-2147221219 (8004011D)':
[Collaboration Data Objects - [MAPI_E_FAILONEPROVIDER(8004011D)]]
仅在对根文件夹 nfo.RootFolder.Name 的引用中引发异常。
2010 不支持此属性吗?
欢迎任何建议,谢谢。