【问题标题】:How to filter uncategorised item in Outlook using vba如何使用 vba 过滤 Outlook 中未分类的项目
【发布时间】:2016-01-25 12:14:54
【问题描述】:

在创建宏时,该宏会从 Outlook 中的所有未分类消息中提取一些数据。我可以通过使用循环并检查收件箱中每封邮件的状态来获取数据,但是收件箱中的邮件数量很大。那么有没有办法只过滤未分类的项目,然后从过滤后的邮件中获取数据。

我尝试了以下代码。但是它对我不起作用。

Mailbox = Cells(k, 1).Value

Set Fldr = olNs.Folders(Mailbox).Folders("inbox")
Fldr.Items.Restrict ("[Category]=[]")

有什么方法可以加快宏的速度。

【问题讨论】:

  • 这可能会有所帮助stackoverflow.com/help/mcve“描述问题。“它不起作用”不是问题陈述。”
  • 它不起作用意味着代码什么都不做。它只返回整个项目

标签: vba email outlook


【解决方案1】:

这描述了如何“Filter Items that Do Not Have Categories

Sub NullCategoryRestriction() 
    Dim oFolder As Outlook.Folder 
    Dim oItems As Outlook.Items 
    Dim Filter As String 

    'DASL Filter can test for null property. 
    'This will return all items that have no category. 
    Filter = "@SQL=" & Chr(34) & _ 
     "urn:schemas-microsoft-com:office:office#Keywords" & _ 
     Chr(34) & " is null" 
    Set oFolder = Application.ActiveExplorer.CurrentFolder 
    Set oItems = oFolder.Items.Restrict(Filter) 
    Debug.Print oItems.Count 
End Sub

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-07-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-01
    • 1970-01-01
    相关资源
    最近更新 更多