Example configuration Microsoft Power Automate to categorize email subject based on Microsoft Dynamics 365
Prerequisites
Introduction
In this guide you will create a Microsoft Power Automate solution, in which you create a Flow that will set a category on an email based on the contact information in Dynamics 365 (in this example Account Relation Status), Learn More
Step 1: Create Outlook rule
The AnywhereNow automatically processes a new email as soon as it enters the Inbox. Because of this reason you first need to create an Outlook rule to move the email in a pre-process folder. Below on how to move all email to a folder. Of course you can create your own rules:
- Open Outlook (web) client.
- Open "Rules, Create New".
- Click "Advanced Options...".
- Click "Next".
- Check "Move it to specified folder".
- Select the folder where you want to move it to, for example "Pre-Process".
- Click "Finish".
Step 2: Create a Microsoft Power Automate Flow
-
Navigate to Microsoft Power Automate.
-
Click "My Flow".
-
Click "New" and "Create from Blank".
-
Select connector "Office 365 Outlook, When a new email arrives".
-
Select the folder you used for the pre-process.
-
-
Add the step "Dynamics 365, List records":
-
Organization Name = Connect to your organization tenant
-
Entity Name = Contacts
-
Filter Query = emailaddress1 eq '@{triggerBody()?['from']}'
-
-
Add the step "Initialize variable":
-
Name = Company
-
Type = String
-
Value:
-
-
Add the step "Dynamics 365, Get record".
-
Organization Name = Connect to your organization tenant
-
Entity Name = Accounts
-
Item identifier:
-
-
Add the step "Initialize variable":
-
Set "TopScoring" as name.
-
Set "Sting" as Type.
-
Set the following Value:
-
-
Add the step "HTTP".
-
Set "Patch" as method.
-
Add the following uri:
-
Add the following body:
CopyExpression{
"Categories":[
"@{body('Get_record')?['_wsp_relationstatus_label']}"
],
"IsRead":true
} -
Tenant = Directory (tenant) ID, found in the App Overview
-
Audience = https://graph.microsoft.com
-
Client ID = Application (client) ID, found in the App Overview
-
Credential Type = "Secret"
-
Secret = Secret, can be created in Azure under "Certificates & Secrets"
-
-
Create a new step "Data Operations, Parse JSON".
-
Create a new step "Office 365 Outlook, Move Email":
-
Set "Message id" as Message Id.
-
Set "Inbox" as Folder.
-