【问题标题】:Mark an item with a particular category用特定类别标记项目
【发布时间】:2011-11-18 08:17:42
【问题描述】:

我想根据项目中的文本将项目标记为特定类别。

我有以下代码。

Sub ProcessRSS()
    ' Read RSS items and process the usful ones.
    Dim objList As Object
    Dim objItem As Object
    Dim iCount As Integer

    Set objList = Application.ActiveExplorer.CurrentFolder.Items
    iCount = 0

    For Each objItem In objList
        If (InStr(objItem.Body, "(WA)") > 0) Then
            objItem.Categories = "Important"
            If (InStr(objItem.Categories, "Important") > 0) Then
                iCount = iCount + 1
            End If
        End If
    Next

    Debug.Print "Marked " & iCount & " RSS Items as important."

End Sub

我选择文件夹然后运行宏,但它不会标记类别。

【问题讨论】:

  • 为什么在您设置类别为“重要”之后检查 objItem.Categories 是否包含“重要”?为什么不在设置 Categories 属性后增加项目数?

标签: vba outlook


【解决方案1】:

您需要在更新类别后.Save 您的商品。下面是带有保存的 For 循环。作为旁注,请记住,您将覆盖任何现有类别,因为.Categories 是一个逗号分隔的字符串。您可能需要测试.Categories 是否为空,如果不是,请添加“,重要”。

For Each objItem In objList
    If (InStr(objItem.Body, "(WA)") > 0) Then
        objItem.Categories = "Important"
        objItem.Save
        If (InStr(objItem.Categories, "Important") > 0) Then
            iCount = iCount + 1
        End If
    End If
Next

【讨论】:

  • 太棒了!无法相信找到我需要的那一点简单信息是如此困难。非常感谢!
猜你喜欢
  • 1970-01-01
  • 2020-07-05
  • 1970-01-01
  • 2012-04-21
  • 2016-03-23
  • 1970-01-01
  • 2017-03-11
  • 2015-09-21
  • 1970-01-01
相关资源
最近更新 更多