我试图根据两个条件从指定的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方法按多个字段过滤需要什么语法?
答案 0 :(得分:2)
首先,":"
末尾有""urn:schemas:httpmail:Received:""
。其次,没有这样的DASL名称。您的意思是"datereceived"
吗?
您需要使用"urn:schemas:httpmail:datereceived"
或"http://schemas.microsoft.com/mapi/proptag/0x0E060040"
。使用OutlookSpy查找DASL属性名称 - 单击IMessage按钮,选择属性,查看DASL编辑框。