harperakm
06-13-2017, 10:33 AM
Hi, I'm trying to sort incoming mail into multiple categories according to keywords in the message body. Currently it's only tagging one category per email, even if multiple keywords are present.
I'm new to vba so this is probably completely wrong, but below is what I have so far (also my code does have indents but I couldn't paste it correctly here):
Sub Categorize(Item As Outlook.MailItem)
Select Case LCase(Item.Body)
Case "keyword1"
Item.Categories = "Category 1"
End Select
Item.Save
Select Case LCase(Item.Body)
Case "keyword2"
Item.Categories = "Category 2"
End Select
Item.Save
Select Case LCase(Item.Body)
Case "keyword3"
Item.Categories = "Category 3"
End Select
Item.Save
End Sub
Help please!
Thanks!
I'm new to vba so this is probably completely wrong, but below is what I have so far (also my code does have indents but I couldn't paste it correctly here):
Sub Categorize(Item As Outlook.MailItem)
Select Case LCase(Item.Body)
Case "keyword1"
Item.Categories = "Category 1"
End Select
Item.Save
Select Case LCase(Item.Body)
Case "keyword2"
Item.Categories = "Category 2"
End Select
Item.Save
Select Case LCase(Item.Body)
Case "keyword3"
Item.Categories = "Category 3"
End Select
Item.Save
End Sub
Help please!
Thanks!