How to get search criteria in Outlook
I am trying to edit the search folder in Outlook. But the search folder is treated like a regular folder: in this MSDN link , MS reports that "GetSearchFolders returns a collection of folders."
I believe that once I have a filter in my search folder, I'll have to delete the current one, edit the filter and create a new one, but that's the easy part. I found for example. here's how to create and delete search folders. Everywhere I find create and delete, but no one seems to know how to edit it or get the filter that relates to it ...
source to share
The Outlook Object Model will not let you edit the search criteria in the search folder.
You can use Extended MAPI (C ++ or Delphi, you can see the search criteria in OutlookSpy if you select the search folder and click on IMAPIFolder and go to the GetSearchCriteria tab) or Redemption (in any language): it provides RDOSearchFolder (allows you to create and manage search folders) and the RDOStore2.Searches collection - it exposes saved searches (backed up by MAPI search folders) visible in the search node folders in Outlook.
UPDATE: The following script will print the search criteria of all searches in the default profile:
set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set Searches = Session.Stores.DefaultStore.Searches
for each Search in Searches
Debug.Print "-------------"
Debug.Print Search.Name & ": "
Debug.Print Search.SearchCriteria.AsSQL
next
source to share