如何在 C# 中的单个 DASL 过滤器查询中使用多个条件? (语法)(对于 advancedSearch() 方法)

How to use multiple conditions in single DASL filter query in C#? (Syntax) (for advancedSearch() method)

截图一:

截图二:

背景:

目前我正在 VSTO 加载项中搜索电子邮件主题中的单词。我的语法是:

string filter = "urn:schemas:mailheader:subject LIKE \'%" + wordInSubject + "%\'";

甚至以下语法也有效:

string filter = String.Format("\"urn:schemas:mailheader:subject\" >= '{0}'", "ticket");

string filter = String.Format("@SQL=(\"urn:schemas:calendar:dtstart\" >= '{0:g}' " + "AND \"urn:schemas:calendar:dtend\" <= '{1:g}' " + "AND \"urn:schemas:mailheader:subject\" LIKE '%{2}%')", startTime, endTime, wordInSubject);

但是,我还想包括邮件在时间范围内的日期时间比较。

研究链接:

doc for multiple conditions

doc with VB syntax

我尝试了以下方法,但是它们不起作用:

string filter = ("urn:schemas:mailheader:subject LIKE \'%" + wordInSubject + "%\'") + ("[Start] >= '" + startTime.ToString("g") + "' + [End] <= '" + endTime.ToString("g") + "'"); 

string filter = ("urn:schemas:mailheader:subject LIKE \'%" + wordInSubject + "%\'") AND ("[Start] >= '" + startTime.ToString("g") + "' AND [End] <= '" + endTime.ToString("g") + "'"); 

此外,在搜索时我读到它应该以“@SQL=”为前缀 - 然而,即使是这种情况也会引发错误:-

string filter = "@SQL=""urn:schemas:mailheader:subject LIKE \'%" + wordInSubject + "%\'"

问题陈述:-

我不是在寻找具体的 DateTime 案例。但是,我可以只使用在单个过滤器字符串(任何类型的条件)中使用多个条件的语法。

link to advancedSearch() Method documentation

尝试以下使用 DASL 属性 名称的查询:

@SQL=("http://schemas.microsoft.com/mapi/proptag/0x0E1D001F" LIKE '%test%') AND ("http://schemas.microsoft.com/mapi/proptag/0x0E060040" > '2017-09-25 00:00:00') AND ("http://schemas.microsoft.com/mapi/proptag/0x0E060040" < '2018-09-25 00:00:00')

它对 PR_NORMALIZED_SUBJECT_W(DASL 名称 http://schemas.microsoft.com/mapi/proptag/0x0E1D001F)和 PR_MESSAGE_DELIVERY_TIME(DASL 名称 http://schemas.microsoft.com/mapi/proptag/0x0E060040)使用限制。

DASL 属性 名称可以在 OutlookSpy 中检索(我是它的作者)- 单击 IMessage 按钮,select 属性,看到 DASL 文本框。

尝试以下使用 DASL 属性 名称的查询:

@SQL=("http://schemas.microsoft.com/mapi/proptag/0x0E1D001F" LIKE '%test%') AND ("http://schemas.microsoft.com/mapi/proptag/0x0E060040" > '2017-09-25 00:00:00') AND ("http://schemas.microsoft.com/mapi/proptag/0x0E060040" < '2018-09-25 00:00:00')

它对 PR_NORMALIZED_SUBJECT_W(DASL 名称 http://schemas.microsoft.com/mapi/proptag/0x0E1D001F)和 PR_MESSAGE_DELIVERY_TIME(DASL 名称 http://schemas.microsoft.com/mapi/proptag/0x0E060040)使用限制。

DASL 属性 名称可以在 OutlookSpy 中检索(我是它的作者)- 单击 IMessage 按钮,select 属性,看到 DASL 文本框。