如何搜索即时搜索Outlook的结果

时间:2019-01-04 20:02:05

标签: vba outlook outlook-vba

我有以下代码可以在Outlook中进行即时搜索,但是我不确定现在如何遍历这些结果以进行进一步的检查。

任何指针将不胜感激!

Sub SearchByAddress()

    Dim myOlApp As New Outlook.Application
    Dim ns As Outlook.NameSpace
    Dim strFilter As String
    Dim oMail  As Outlook.MailItem

    Set ns = myOlApp.GetNamespace("MAPI")

          strFilter = "joebloggs@hotmail.com"

    Set myOlApp.ActiveExplorer.CurrentFolder = ns.GetDefaultFolder(olFolderInbox)
         txtSearch = "from:(" & Chr(34) & strFilter & Chr(34) & ") AND " & Chr(34) & "Check" & Chr(34)
         myOlApp.ActiveExplorer.Search txtSearch, olSearchScopeAllFolders

    Set myOlApp = Nothing



End Sub

1 个答案:

答案 0 :(得分:0)

改为使用Application.AdvancedSearch-它返回Search对象的实例。