Category Change


Add the following code to the ThisOutlookSession


Private WithEvents explorerItem As Outlook.Explorer 
Private WithEvents mailItem As Outlook.mailItem
 
Private Sub Application_Startup()
  Set explorerItem = Application.ActiveExplorer
End Sub

Private Sub explorerItem_SelectionChange()
Dim obj As Object
Dim Sel As Outlook.Selection

  Set mailItem = Nothing
  Set Sel = explorerItem.Selection
  If Sel.Count > 0 Then
    Set obj = Sel(1)
    If (TypeOf obj Is Outlook.mailItem) Then
      Set mailItem = obj
    End If
  End If
End Sub

Private Sub mailItem_PropertyChange(ByVal Name As String)
Dim newValue As String
  Debug.Print Name
  If Name = "FlagStatus" Then
      Select Case mailItem.FlagStatus
         Case OlFlagStatus.olFlagComplete: newValue = "Complete"
         Case OlFlagStatus.olFlagMarked: newValue = "Marked"
         Case OlFlagStatus.olNoFlag: newValue = "No Flag"
      End Select
      If (newValue <> "Marked") Then
         Call MsgBox("The Flag Status has been changed to '" & newValue & "'", _
                     vbInformation, "Follow Up Changed")
      End If
  End If
  
  If Name = "Categories" Then
      newValue = mailItem.Categories
      Call MsgBox("The Category has been changed to '" & newValue & "'", _
                  vbInformation, "Category Changed")
  End If
End Sub


© 2025 Better Solutions Limited. All Rights Reserved. © 2025 Better Solutions Limited TopPrev