Hunter B
Hunter B

Reputation: 53

Add A New Outlook Mail Category

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

Answers (1)

Hunter B
Hunter B

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

Related Questions