Missing
Private WithEvents Items As Items
https://msdn.microsoft.com/en-us/lib...ffice.14).aspx
Option Explicit
Private WithEvents Items As Items
Private Sub Application_Startup()
Dim Msg As Outlook.MailItem
Dim Ns As Outlook.Namespace
Set Ns = Application.GetNamespace("MAPI")
Set Items = Ns.GetDefaultFolder(olFolderInbox).Items
End Sub
Private Sub Items_ItemChange(ByVal Item As Object)
Dim oRespond As Outlook.MailItem
If TypeOf Item Is Outlook.MailItem And Item.Categories = "xyz" Then
Set oRespond = Application.CreateItemFromTemplate("file path here")
With oRespond
.Recipients.Add Item.SenderEmailAddress
.Subject = "Re: xyz - " & Item.Subject
.HTMLBody = oRespond.HTMLBody & vbCrLf & "--- original message attached ---" & vbCrLf & Item.HTMLBody & vbCrLf
.Attachments.Add Item
.Display
'.send
End With
Set oRespond = Nothing
Else
MsgBox "My macro repeats the above If statement with different category"
End If
End Sub