我正在尝试将进入共享收件箱(ABC COMPANY)的某些电子邮件移动到在主文件夹(DAILY INFO)中创建的子文件夹(A&D)。我仅在网络上找到一个宏,该宏将电子邮件从共享收件箱移至主文件夹,但未移至子文件夹。这是我找到的代码。
Dim NS As NameSpace
Dim sharedInbox As folder
Dim sharedDestinationFolder As folder
Dim sharedItems As Selection
Dim i As Long
Set NS = Application.GetNamespace("MAPI")
Set sharedInbox = NS.Folders("ABC COMPANY").Folders("Inbox")
Set sharedDestinationFolder = sharedInbox.Folders("DAILY INFO")
Set sharedItems = ActiveExplorer.Selection
' Counting in reverse
'when changing the number of items in a collection
For i = sharedItems.Count To 1 Step -1
sharedItems(i).Move sharedDestinationFolder
Next i
ExitRoutine:
Set NS = Nothing
Set sharedItems = Nothing
Set sharedInbox = Nothing
Set sharedDestinationFolder = Nothing
End Sub
答案 0 :(得分:1)
每个folder
都包含一个folders
集合,其中包含其子文件夹。
假设您的文件夹存在,请执行类似的操作
Set sharedDestinationFolder = sharedInbox.Folders("DAILY INFO")
Set sharedDestinationFolder = sharedDestinationFolder.Folders("A&D")
当然,您可以使用一条语句来完成此操作,但这会使某些情况下的调试更加困难
Set sharedDestinationFolder = sharedInbox.Folders("DAILY INFO").Folders("A&D")