如何遍历共享邮件收件箱文件夹的子文件夹的子文件夹? [英] How can one iterate through the subfolders of a subfolder of a shared mail inbox folder?
本文介绍了如何遍历共享邮件收件箱文件夹的子文件夹的子文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以此为基础,这里,如何遍历共享邮箱收件箱文件夹的子文件夹?
Building up on this one, here, how can one iterate through the subfolders of a subfolder of the inbox folder of a shared mailbox?
到目前为止我没有找到解决方案.
I'm failing to find a solution so far.
希望我们能找到答案.
推荐答案
以下代码将从您定义的基本文件夹中创建文件夹结构的字典,然后您可以对其进行操作
The following code will create a dictionary of the folder structure from your defined base folder which you can then manipulate
Sub RecurseFolderStructure()
' Requires Reference: Microsoft Scripting Runtime
Dim ThisNamespace As Outlook.NameSpace: Set ThisNamespace = Application.GetNamespace("MAPI")
Dim Inbox As Outlook.MAPIFolder: Set Inbox = ThisNamespace.GetDefaultFolder(olFolderInbox)
Dim Junk As Outlook.MAPIFolder: Set Junk = ThisNamespace.GetDefaultFolder(olFolderJunk)
Dim BaseFolder As Outlook.MAPIFolder: Set BaseFolder = Inbox '.Folders("SubFolder1\SubFolder2...")
Dim Folders As Scripting.Dictionary: Set Folders = New Scripting.Dictionary
AddSubFolders BaseFolder, Folders
Dim Key As Variant
For Each Key In Folders
'Further Code; for eg.
Debug.Print Key, Folders(Key)
Next Key
Folders.RemoveAll
Set Folders = Nothing
End Sub
Function AddSubFolders(CurrentFolder As Outlook.MAPIFolder, dict As Scripting.Dictionary)
Dim Folder As Outlook.MAPIFolder
If Not dict.Exists(CurrentFolder.FolderPath) Then dict.Add CurrentFolder.FolderPath, CurrentFolder
If CurrentFolder.Folders.Count > 0 Then
For Each Folder In CurrentFolder.Folders
AddSubFolders Folder, dict
Next
End If
End Function
这篇关于如何遍历共享邮件收件箱文件夹的子文件夹的子文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文