兑换示例代码中如何判断对象类型
Redemption how to determine object types in example code
我刚开始使用 Redemption,不太确定如何使用 Doc。
我使用 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)
Return 一个没有 ulFuzzyLevel、ulPropTag 和 lpProp 等属性的 _Restriction 对象。
第二个问题是如何像在OOM中创建一个搜索文件夹。由于性能问题,我不想使用 OOM。 Redemption 可以安装在没有 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");
NewSearchFolder.SearchCriteria.SetKind
将 return 一个不同的对象(全部派生自 Restriction
对象),具体取决于您传入的参数 - 对于 RES_CONTENT
类型,您会返回RestrictionContent
对象。只需适当地转换 returned 值。
另请注意,Redemption 需要安装 MAPI 系统才能正常运行,这意味着必须安装 Outlook 或独立版本的 MAPI。
我刚开始使用 Redemption,不太确定如何使用 Doc。 我使用 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)
Return 一个没有 ulFuzzyLevel、ulPropTag 和 lpProp 等属性的 _Restriction 对象。
第二个问题是如何像在OOM中创建一个搜索文件夹。由于性能问题,我不想使用 OOM。 Redemption 可以安装在没有 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");
NewSearchFolder.SearchCriteria.SetKind
将 return 一个不同的对象(全部派生自 Restriction
对象),具体取决于您传入的参数 - 对于 RES_CONTENT
类型,您会返回RestrictionContent
对象。只需适当地转换 returned 值。
另请注意,Redemption 需要安装 MAPI 系统才能正常运行,这意味着必须安装 Outlook 或独立版本的 MAPI。