Search code examples
vbaoutlook

Can Not Is Nothing determine if an item has a category?


A macro at work, in a shared mailbox, doesn’t always trigger correctly.

Is

If objItem.Categories <> "" Then

as ‘effective’ as

If Not objItem.Categories Is Nothing Then

Alternatively, would a select case statement with 60 case outcomes not trigger correctly?


Solution

  • The MailItem.Categories property returns a string representing the categories assigned to the Outlook item.

    In VBA you can just check whether it is an empty string or not. So, the following check is correct:

    If objItem.Categories <> "" Then …