vba - 使用特定类别标记项目

标签 vba outlook

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

我有以下代码。

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

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

最佳答案

您需要.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

关于vba - 使用特定类别标记项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7439187/

相关文章:

excel - 将满足特定条件的数据从一个工作表复制到另一个工作表

vba - 来自 VBA Excel 的 Shell Camera.exe

sharepoint - 如何在SharePoint工作流中摆脱用户的办公室状态

python - 如何让Python在Excel应用程序打开时更改xlsx文件?

Excel 加载项有时无法加载

javascript - 我如何将 Outlook Web App 嵌入到我的站点中?

c# - 如何在 ASP.NET 中使用 Exchange Web 服务下载未读的电子邮件附件?

c# - Outlook VSTO 功能区到主页 tabControlId

Outlook 中的 HTML 电子邮件背景中断布局 - 使用 vml 方法

excel - VBA选择范围然后调整范围大小