将对象存储 (Outlook)
Store 对象的集合,代表当前配置文件中提供的所有存储区。
使用 Stores 和 Store 对象枚举当前会话中所有存储区的所有文件夹和搜索文件夹。 有关在文件夹和存储区中存储 Outlook 项目的详细信息,请参阅存储 Outlook 项目。
以下 Microsoft Visual Basic for Applications (VBA) 代码示例枚举某个会话的所有存储区上的所有文件夹:
Sub EnumerateFoldersInStores()
Dim colStores As Outlook.Stores
Dim oStore As Outlook.Store
Dim oRoot As Outlook.Folder
On Error Resume Next
Set colStores = Application.Session.Stores
For Each oStore In colStores
Set oRoot = oStore.GetRootFolder
Debug.Print (oRoot.FolderPath)
EnumerateFolders oRoot
Next
End Sub
Private Sub EnumerateFolders(ByVal oFolder As Outlook.Folder)
Dim folders As Outlook.folders
Dim Folder As Outlook.Folder
Dim foldercount As Integer
On Error Resume Next
Set folders = oFolder.folders
foldercount = folders.Count
'Check if there are any folders below oFolder
If foldercount Then
For Each Folder In folders
Debug.Print (Folder.FolderPath)
EnumerateFolders Folder
Next
End If
End Sub
名称 |
---|
项 |
有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。