How to get a search folder criteria in Outlook

£可爱£侵袭症+ 提交于 2020-01-04 03:13:10

问题


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...


回答1:


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 if you select the search folder and click the IMAPIFolder button and go to the GetSearchCriteria tab) or Redemption (any language): 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


来源:https://stackoverflow.com/questions/26020971/how-to-get-a-search-folder-criteria-in-outlook

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!