Outlook Object Model 2010: Programmatically check whether the search is synchronous or not?

In Outlook 2010, you have a way to check whether the search is synchronous or asynchronous or not. Just created a small code snippet (below) for the reference – you can notice that I just call the application.IsSearchSynchronous() and pass the look in folder which want to try. The path name of the folders that the search will search through. Code snippet:

    1: Sub TestSearch()
    2:  
    3:  Dim fpath As String
    4:  Dim oStre As Outlook.Store
    5:  
    6:  For Each oStre In Outlook.Session.Stores
    7:  fpath = "'" & oStre.GetRootFolder.folderPath & "'"
    8:  Debug.Print fpath & " IsSearchSynchronous = " & Application.IsSearchSynchronous(fpath)
    9:  Next
   10:  
   11: End Sub

Output:

image

Note:

+ You must enclose the folder path (fpath) with single quotes – refer the above example

+ If the search is synchronous, the AdvancedSearch method will not return until the search has completed. + On the contrary, if the search is asynchronous, the AdvancedSearch method will immediately return. + In order to get meaningful results from an asynchronous search, use the AdvancedSearchComplete event to notify you when the search has finished.

Happy programming!!