【问题标题】:Search string syntax for Restrict method搜索限制方法的字符串语法
【发布时间】:2016-12-12 19:03:08
【问题描述】:

我正在尝试根据两个条件从指定的 Outlook 文件夹中提取一组五封电子邮件 - (部分)主题行,并在两个指定日期之间收到。我过去曾使用Items.Restrict 方法完成类似的任务,只过滤部分主题行,但我也在努力包含日期。

我的模板,正常工作的那行,如下所示:

strFilter = "@SQL=""urn:schemas:httpmail:subject"" like '%" & strSubject & "%'"
Set itmFiltered = fld.Items.Restrict(strFilter)

我尝试过以各种方式包含日期。根据帮助文件,我认为这样的事情会起作用:

strFilter = "@SQL=""urn:schemas:httpmail:subject"" like '%" & strSubject & "%'"
If Len(strStart) <> 0 then
    strfilter = strfilter & " AND ""urn:schemas:httpmail:Received:"" >='" & strStart & "'"
End If

set itmFiltered = fld.Items.Restrict(strfilter)

每次都出错。

我还尝试将其设置为仅按日期过滤,不包括主题行,如下所示:

strFilter = "@SQL=""urn:schemas:httpmail:Received: >=""'" & strStart & "'"

再一次,没有运气。

所以,我的问题:

使用 Items.Restrict 方法按日期过滤需要什么语法?

使用 Items.Restrict 方法按多个字段过滤需要什么语法?

【问题讨论】:

    标签: vba outlook


    【解决方案1】:

    首先,您在""urn:schemas:httpmail:Received:"" 的末尾有一个":"。其次,没有这样的DASL名称。你是说"datereceived"吗?

    您需要使用"urn:schemas:httpmail:datereceived""http://schemas.microsoft.com/mapi/proptag/0x0E060040"。使用OutlookSpy 查找DASL 属性名称-单击IMessage 按钮,选择属性,查看DASL 编辑框。

    【讨论】:

    • 看起来不错;谢谢!是的,我一直在努力寻找任何地方引用的 DASL。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-18
    • 1970-01-01
    • 2012-01-24
    • 1970-01-01
    相关资源
    最近更新 更多