我正在尝试从 Excel 中查看与某些参数匹配的邮件项目的所有 Outlook 文件夹以保存附件。
我不知道如何引用范围来遍历所有文件夹,甚至是自定义文件夹。
我找不到能回答我问题的资源。
Sub testing()
Dim myOlApp As New Outlook.Application
Dim scope As String
Dim filter As String
Dim rsts As Results
Dim AdvancedSearch As Outlook.Search
blnSearchComp = False
'I want it to search the entire mail account including normal folders like inbox and sent as well as custom folders.
'but this doesn't work. Any ideas?
scope = "'Fakeexample123@outlook.com'"
'filter assignment statement has been excluded
Set AdvancedSearch = myOlApp.AdvancedSearch(scope, filter, True, "test")
While blnSearchComp <> True
If AdvancedSearch.Results.Count > 0 Then
blnSearchComp = True
End If
Wend
Set rsts = AdvancedSearch.Results
For x = rsts.Count To 1 Step -1
rsts.Attachment.Item(x).SaveAsFile Project
Next
End Sub