cancel
Showing results for 
Search instead for 
Did you mean: 
VJR
Multi Super User

How to set Categories to one or more emails in Outlook using Power Automate Desktop?

Problem Statement:

Power Automate Desktop currently does not have an option to set categories to Outlook emails.

 

These are what categories in Outlook are. They can be default ones like Blue Category, Orange Category, or you can customize your own ones as shown below.

 

VJR_0-1708414321517.png

 

 

Power Automate Desktop Solution:

 

1. Launch Outlook and Configure the desired parameters for retrieving emails as per your specific criteria.

Here the email with the subject as "test email" in Inbox folder is configured.

 

VJR_1-1708414478100.png

 

 

2.  For the sake of this example only 1 email with the subject "test email" will be retrieved.

Hence, we are storing the unique EntryID of that email in a variable.

 

VJR_2-1708414539921.png

 

 

3. Here we are setting a variable with the desired Outlook categories

- Can pass single or as shown we are passing two categories at once.

IMP: Make sure that you have the correct spelling of the category name as per the list of already configured categories in the outlook application. First screenshot of this write-up.

 

VJR_3-1708414633208.png

 

 

4.  Here we are simply passing the above two variables to a Vbscript which will do the rest ie; setting the category to the email having the specified EntryID.

 

VJR_4-1708414738826.png

 

 

VBScript Code:

 

Option Explicit

' Create Outlook Application object
Dim objOutlook
Set objOutlook = CreateObject("Outlook.Application")

' Get the message by its ID
Dim objNamespace, objMessage
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objMessage = objNamespace.GetItemFromID("%EntryID%")

' Check if the message is found
If Not objMessage Is Nothing Then
    ' Set the category
    objMessage.Categories = "%CategoriesToSet%"
    objMessage.Save ' Save changes
    
   ' MsgBox "Category set successfully."
Else
    'MsgBox "Message not found."
End If

' Clean up
Set objMessage = Nothing
Set objNamespace = Nothing
Set objOutlook = Nothing

 

5. The overall PAD flow would look as below.

 

*I have also attached the txt file of the entire flow which you need to copy-paste inside a blank Flow editor.

The flow is built in PAD version 2.41

 

VJR_5-1708414920525.png

6. Thats it. The email output after running the above PAD flow is as follows.

 

VJR_7-1708414990467.png

 

 

7. Attached .txt file of the flow to copy-paste into a blank PAD editor.

When you copy paste the code chances are that Power Automate Desktop adds some slash characters especially in the vbscript and you may see some errors. Single back slashes may become double back slashes. To fix, take the vbscript code snippet posted above and paste it directly into the "Run vbscript" action. 

 

 

About the Author
  • Experienced Consultant with a demonstrated history of working in the information technology and services industry. Skilled in Office 365, Azure, SharePoint Online, PowerShell, Nintex, K2, SharePoint Designer workflow automation, PowerApps, Microsoft Flow, PowerShell, Active Directory, Operating Systems, Networking, and JavaScript. Strong consulting professional with a Bachelor of Engineering (B.E.) focused in Information Technology from Mumbai University.
  • I am a Microsoft Business Applications MVP and a Senior Manager at EY. I am a technology enthusiast and problem solver. I work/speak/blog/Vlog on Microsoft technology, including Office 365, Power Apps, Power Automate, SharePoint, and Teams Etc. I am helping global clients on Power Platform adoption and empowering them with Power Platform possibilities, capabilities, and easiness. I am a leader of the Houston Power Platform User Group and Power Automate community superuser. I love traveling , exploring new places, and meeting people from different cultures.
  • Read more about me and my achievements at: https://ganeshsanapblogs.wordpress.com/about MCT | SharePoint, Microsoft 365 and Power Platform Consultant | Contributor on SharePoint StackExchange, MSFT Techcommunity
  • Encodian Owner / Founder - Ex Microsoft Consulting Services - Architect / Developer - 20 years in SharePoint - PowerPlatform Fan
  • Founder of SKILLFUL SARDINE, a company focused on productivity and the Power Platform. You can find me on LinkedIn: https://linkedin.com/in/manueltgomes and twitter http://twitter.com/manueltgomes. I also write at https://www.manueltgomes.com, so if you want some Power Automate, SharePoint or Power Apps content I'm your guy 🙂
  • I am the Owner/Principal Architect at Don't Pa..Panic Consulting. I've been working in the information technology industry for over 30 years, and have played key roles in several enterprise SharePoint architectural design review, Intranet deployment, application development, and migration projects. I've been a Microsoft Most Valuable Professional (MVP) 15 consecutive years and am also a Microsoft Certified SharePoint Masters (MCSM) since 2013.
  • Big fan of Power Platform technologies and implemented many solutions.
  • Passionate #Programmer #SharePoint #SPFx #M365 #Power Platform| Microsoft MVP | SharePoint StackOverflow, Github, PnP contributor
  • Web site – https://kamdaryash.wordpress.com Youtube channel - https://www.youtube.com/channel/UCM149rFkLNgerSvgDVeYTZQ/