Reputation: 116
I am trying to edit a search folder in Outlook. But a search folder is treated as a regular folder: in this MSDN reference, MS informs that "GetSearchFolders returns a Folders collection".
I believe that, once I have the search folder filter, I will have to delete the current, edit the filter and create a new one - but that's the easy part. I have found e.g. here how to create and delete search folders. Everywhere I find create and delete, but nobody seems to know how to edit it or get the filter that applies to it...
Upvotes: 4
Views: 2198
Reputation: 66215
Outlook Object Model will not let you edit the search criteria of a Search folder.
You can either use Extended MAPI (C++ or Delphi, you can see the search criteria in OutlookSpy (I am its author) if you select the search folder and click the IMAPIFolder button and go to the GetSearchCriteria tab) or Redemption (any language - I am also its author): it exposes the RDOSearchFolder object (lets you create and manage MAPI search folders) and RDOStore2.Searches collection - it exposes saved searches (backed up by MAPI search folders) visible under the Search Folders node 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
Upvotes: 2