如何从Excel VBA中的其他邮件项目中筛选今天收到的Outlook邮件项目 [英] How to filter Outlook mail items received by today from other mail items in Excel VBA

查看:300
本文介绍了如何从Excel VBA中的其他邮件项目中筛选今天收到的Outlook邮件项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Excel宏(VBA)的新手. 我们有一个Excel宏应用程序,在其中我试图从其他邮件中过滤今天收到的Outlook邮件.我尝试了限制方法. 这是现在看起来的代码

I am new to Excel macros (VBA). We have an Excel macro application in which I am trying to filter outlook mail items received by today from other mail items. I have tried Restrict method. Here is the code looks now

Set Fldr1 = olNs.GetDefaultFolder(olFolderInbox).Folders.Item("Folder name")
olMiArr=Fldr1.Items.Restrict("DateValue[ReceivedTime]='DateValue(Now)'")

但是它会在执行时引发错误.对此表示任何赞赏.

But it throws error on execution. Any comment on this is highly appreciated.

推荐答案

要确保日期格式符合Microsoft Outlook的预期格式,请使用Format函数.例如:

To make sure that the date is formatted as Microsoft Outlook expects, use the Format function. For example:

Items.Restrict("DateValue[ReceivedTime]='" & Format(DateValue(Now),"ddddd h:nn AMPM") & "'")

还要注意限制方法会应用过滤到Items集合,并返回一个新集合,其中包含与过滤器匹配的原始项目中的所有项目.

Also pay attention to the fact that the Restrict method applies a filter to the Items collection, returning a new collection containing all of the items from the original that match the filter.

这篇关于如何从Excel VBA中的其他邮件项目中筛选今天收到的Outlook邮件项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆