I copy pasted it at the top of the ThisOutlookSession.
the error message is gone now, but it still doesn't run automatically...
Regarding the attachement, this portion of code can be part of my main code?
Like:
Or should it be part of a different macro?Public Sub autocategories() Dim olItem As Object For Each olItem In Application.ActiveExplorer.Selection If InStr(1, olItem.Subject, "[cat1]", vbTextCompare) > 0 Then olItem.Categories = "CAT1" ElseIf InStr(1, olItem.Subject, "[cat2]", vbTextCompare) > 0 Then olItem.Categories = "CAT2" For i = 1 To olItem.Attachments.Count If InStr(1, olItem.Attachments(i).fileName, "[CAT1]", vbTextCompare) > 0 Then olItem.Categories = "CAT1" olItem.Save Exit For End If Next i olItem.Save Next olItem Set olItem = Nothing End Sub




Reply With Quote