Power Community

Power Community

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.


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.


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.


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.


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.


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."
    '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


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


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. 

Set Outlook Categories.zip

This post was originally published on this site

- Advertisement -spot_img


Please enter your comment!
Please enter your name here

- Advertisement - Advertisement

Latest News

5 Benefits of In-App Notifications for Microsoft Dynamics 365 CRM users

For a successful sales process, you need to stay up-to-date with crucial sales information like deal closures, opportunities won,...

More Articles Like This

- Advertisement -spot_img