为什么这个Outlook 2007版本的VBA工作(我正在尝试用程序来删除一个标记)?

时间:2022-08-23 11:49:55

I have some code that adds a flag to an email but when I try this code below to remove it, it doesn't seem to have any effect in Outlook 2007.

我有一些在电子邮件中添加标记的代码,但是当我尝试下面的代码删除它时,它在Outlook 2007中似乎没有任何效果。

    Public Sub Clear()
        Dim objOutlook As Outlook.Application
        Dim objInspector As Outlook.Inspector

        Dim strDateTime As String

        ' Instantiate an Outlook Application object.
        Set objOutlook = CreateObject("Outlook.Application")

        ' The ActiveInspector is the currently open item.
        Set objExplorer = objOutlook.ActiveExplorer

        ' Check and see if anything is open.
        If Not objExplorer Is Nothing Then
            ' Get the current item.
            Dim arySelection As Object
            Set arySelection = objExplorer.Selection

            For x = 1 To arySelection.Count
                Dim m As MailItem
                Set m = arySelection.Item(x)
                m.Categories = ""
                m.FlagStatus = olNoFlag
                m.FlagIcon = 0
                m.Save
            Next x

        Else
            ' Show error message with only the OK button.
            MsgBox "No explorer is open", vbOKOnly
        End If

    End Sub

1 个解决方案

#1


2  

Outlook 2007 doesn't support 2003 - style flags anymore (it maps them onto a task flag and the most appropriate category color).

Outlook 2007不再支持2003样式的标志(它将它们映射到任务标志和最合适的类别颜色)。

The flag you are trying to clear is probably a task flag. In that that case, performing a

您试图清除的标志可能是一个任务标志。在这种情况下,执行a

m.ClearTaskFlag
m.Save

will do the job.

将做这项工作。

#1


2  

Outlook 2007 doesn't support 2003 - style flags anymore (it maps them onto a task flag and the most appropriate category color).

Outlook 2007不再支持2003样式的标志(它将它们映射到任务标志和最合适的类别颜色)。

The flag you are trying to clear is probably a task flag. In that that case, performing a

您试图清除的标志可能是一个任务标志。在这种情况下,执行a

m.ClearTaskFlag
m.Save

will do the job.

将做这项工作。