Reputation: 53
How can I use VB.net to check if a mail category exists, and if not, create it?
I’m using Visual Studio to create a VSTO outlook add-in. Thanks!
Upvotes: 1
Views: 270
Reputation: 53
After a bunch of trial and error, this code worked:
myOlApp = CreateObject("Outlook.Application")
Dim ns As Outlook.NameSpace = myOlApp.GetNamespace("MAPI")
If IsNothing(ns.Categories("CATEGORYNAME")) = True Then
ns.Categories.Add("CATEGORYNAME", 18)
End If
Upvotes: 1