我正在Outlook 2016中组织电子邮件,我需要在每个文件夹中创建3个特定的子文件夹(我有3000多个文件夹需要这样做)。我有自动在每个文件夹中自动创建3个文件夹的代码,其运行方式如下:
Public Sub CreateFolders()
Dim CurrentFolder As Outlook.MAPIFolder
Dim Subfolder As Outlook.MAPIFolder
Dim List As New VBA.Collection
Dim Folders As Outlook.Folders
Dim Item As Variant
List.Add Array("1", olFolderInbox)
List.Add Array("2", olFolderInbox)
List.Add Array("3", olFolderInbox)
Set CurrentFolder = Application.ActiveExplorer.CurrentFolder
Set Folders = CurrentFolder.Folders
For Each Item In List
Folders.Add Item(0), Item(1)
Next
End Sub
(我是从https://www.computergaga.com/blog/loop-through-subfolders-using-filesystemobject/获得的)
我不知道如何使它在目录的所有子文件夹中自动创建3个文件夹。我真的很陌生,我一直在四处张望,但找不到适合该任务的任何东西。
所有帮助将不胜感激。
答案 0 :(得分:0)
这是我用来遍历所有子文件夹的子文件夹,它只是为每个新的子文件夹调用子文件夹,然后循环遍历子子文件夹,然后子子文件夹等。
Public Sub LoopAllSubFolders(ByVal folder As object)
For Each subfolder In folder.SubFolders
LoopAllSubFolders subfolder 'remove this if you only want to add the folders to the first subfolder
'do stuff with folders, example: subfolder.Name = "this is a file.exe"
Next
End Sub
答案 1 :(得分:0)
如果您要像现在怀疑的那样在 Inside 文件夹中操作Outlook,那么我会在这些资源中寻找答案(因为我不熟悉):
https://www.experts-exchange.com/questions/20301462/Setting-MAPIfolder-properties-in-Outlook的-VBA.html