Есть ли способ добавить определенную категорию и пометить письмо в VBA? - PullRequest
0 голосов
/ 14 ноября 2009

Я обычно просматриваю свою электронную почту и отмечаю что-либо для последующего наблюдения и делюсь на:

  1. Телефонный звонок
  2. E-mail
  3. Поговорите с
  4. Настройка собрания

Есть ли какой-либо способ в макросе Outlook VBA, я могу (в одном макросе) пометить элемент для отслеживания и установить для него одну из вышеуказанных категорий?

1 Ответ

1 голос
/ 15 ноября 2009

Я нашел ответ. .перечислено ниже . , .

Private Sub TagArchived1(category As String)

    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 = category
            m.FlagStatus = olFlagMarked
            m.FlagIcon = 6
            m.Save
        Next x

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

    ' Set all objects equal to Nothing to destroy them and
    ' release the memory and resources they take.
    Set objOutlook = Nothing
    Set objExplorer = Nothing
End Sub
...