Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I'm accessing Outlook via Excel because my enterprise Outlook VBA has been disabled. I'm specifically iterating though my Inbox and updating Mail.object categories property.

Dim objOutlook As Object
Set ObjOUtlook =CreateObject("Outlook.Application")
Dim objNSpace As object
Set ObjNSpace = objNaspace.GetDefaultFolder(olFolderInbox)
Dim myFolder As Object
Set myFolder= objNSpace.GetDefaultFolder(olFolderInbox)
Dim myItems As Outlook.Items
Set myItems = myFolder.Items
For Each objItem In myFolder.items
Dim objMail As Outlook.MailItem
set objMail = objItem
objMail.Categories = "Blue"
objMail.Save

This gives the Blue category in the picture but I want to be able update with the Orange Category formatting.

Can this be achieved through excel VBA?

Unless you have something strange going on here, you just change this line:

objMail.Categories = "Blue"

objMail.Categories = "Orange Category"

The name in the double quotes needs to be exactly the same as the one you have setup in Outlook - ie it's case sensitive.

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.