You could run the AutoCategorize macro below as a script from a rule that applies to all incoming messages, but as you said you were reluctant to use a rule, you could add the following to the ThisOutlookSession module
Option Explicit
Private WithEvents Items As Outlook.Items
Private Sub Application_Startup()
Dim olApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Set olApp = Outlook.Application
Set objNS = olApp.GetNamespace("MAPI")
Set Items = objNS.GetDefaultFolder(olFolderInbox).Items
lbl_Exit:
Exit Sub
End Sub
Private Sub Items_ItemAdd(ByVal item As Object)
On Error GoTo ErrorHandler
If TypeName(item) = "MailItem" Then
AutoCategorize item
End If
lbl_Exit:
Exit Sub
ErrorHandler:
MsgBox Err.Number & " - " & Err.Description
Err.Clear
GoTo lbl_Exit
End Sub
In a normal module enter the modified version of the code below, then restart Outlook (or manually run Application_Startup) to activate the event.
Public Sub AutoCategorize(olItem As MailItem)
With olItem
If InStr(1, olItem.Subject, "[CAT1]", vbTextCompare) > 0 Then
olItem.Categories = "CAT1"
olItem.Save
ElseIf InStr(1, olItem.Subject, "[CAT2]", vbTextCompare) > 0 Then
olItem.Categories = "CAT2"
olItem.Save
ElseIf InStr(1, olItem.Subject, "[CAT3]", vbTextCompare) > 0 Then
olItem.Categories = "CAT3"
olItem.Save
End If
End With
lbl_Exit:
Exit Sub
End Sub
'Beers' can be delivered to my web site