兑换示例代码中如何确定对象类型

时间:2018-08-20 07:37:16

标签: outlook-redemption

我刚开始使用Redemption,但不确定如何使用文档。 我使用C#VS2017和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

关于创建搜索文件夹的关于示例。当我尝试在C#中执行相同操作时,

NewSearchFolder.SearchCriteria.SetKind(RES_CONTENT)

返回一个_Restriction对象,该对象不具有ulFuzzyLevel,ulPropTag和lpProp之类的属性。

第二个问题是如何在OOM中创建搜索文件夹。由于性能问题,我不想使用OOM。兑换可以安装在没有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 个答案:

答案 0 :(得分:1)

NewSearchFolder.SearchCriteria.SetKind将根据您传入的参数返回不同的对象(均从Restriction对象派生)-对于RES_CONTENT类型,您将返回RestrictionContent对象。只需适当地转换返回的值即可。

还请记住,“兑换”必须安装MAPI系统才能正常运行,这意味着必须安装Outlook或MAPI的独立版本。