Redemption how to determine object types in example code

北慕城南 提交于 2019-12-11 17:45:53

问题


I just start using Redemption and not really sure how to use the Doc. I using C# VS2017 and Redemption 5.17.

RES_CONTENT = 3
FL_SUBSTRING = 1
FL_IGNORECASE = &H10000
PR_SUBJECT = &H0037001E
'create new search folder
set Session = CreateObject("Redemption.RDOSession")
Session.Logon
set DefaultStore = Session.Stores.DefaultStore
set SearchRootFolder = DefaultStore.SearchRootFolder
set NewSearchFolder = SearchRootFolder.Folders.AddSearchFolder("Test 
Redemption Search Folder")
'set the restriction to search for message with the word "test" in the 
subject line
set Restriction = NewSearchFolder.SearchCriteria.SetKind(RES_CONTENT)
Restriction.ulFuzzyLevel = FL_SUBSTRING or FL_IGNORECASE
Restriction.ulPropTag = PR_SUBJECT
Restriction.lpProp = "test"
'specify that the search should be performed in the Inbox and Sent Items 
folders

The about example for creating a search folder. When I try to do the same in C# the line

NewSearchFolder.SearchCriteria.SetKind(RES_CONTENT)

Return a _Restriction object which do not have properties like ulFuzzyLevel, ulPropTag and lpProp.

Second question is how to create a search folder like in OOM. I don't want to use OOM, because of performance problem. Redemption can be installed on a machine that don't have Outlook.

   Microsoft.Office.Interop.Outlook.Application outlookApplication = new Microsoft.Office.Interop.Outlook.Application();
            MAPIFolder rootfolder = outlookApplication.ActiveExplorer().CurrentFolder.Store.GetRootFolder();
            string sFolderPath = rootfolder.FolderPath;
            string sScope = "SCOPE ('deep traversal of \"" + sFolderPath + "\"')";
            string sFilter = "\"urn:schemas-microsoft-com:office:office#Keywords\" = 'Danger'";
            Search oSearch = outlookApplication.AdvancedSearch(sScope, sFilter, false, "Danger");
            MAPIFolder oSearchFolder = oSearch.Save("Danger");

回答1:


NewSearchFolder.SearchCriteria.SetKind will return a different object (all derived from Restriction object) depending on the parameter you pass in - for the RES_CONTENT type, you get back RestrictionContent object. Just cast the returned value appropriately.

Also keep in mind that Redemption needs to have the MAPI system installed to function properly, which means either Outlook or the standalone version of MAPI must be installed.



来源:https://stackoverflow.com/questions/51926042/redemption-how-to-determine-object-types-in-example-code

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