Example configuration Microsoft Power Automate to categorize email subject based on Microsoft Dynamics 365
Prerequisites
-
Azure Graph API, with the following permission:
- Type = Application
- Permissions = Mail.ReadWrite
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 Anywhere365 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
-
From your Office Portal, go to your Power Automate App.
-
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:
first(body('List_records')?['value'])?['_parentcustomerid_value']
-
-
Add the step "Dynamics 365, Get record".
-
Organization Name = Connect to your organization tenant
-
Entity Name = Accounts
-
Item identifier:
@{variables('Company')}
-
-
Add the step "Initialize variable":
-
Set "TopScoring" as name.
-
Set "Sting" as Type.
-
Set the following Value:
first(body('Parse_JSON')?['Results']?['output1']?['value']?['Values'])
-
-
Add the step "HTTP".
-
Set "Patch" as method.
-
Add the following uri:
https://graph.microsoft.com/v1.0/users/[user id]/messages/[Message id]
-
Add the following body:
{
"Categories": [
"@{body('Get_record')?['_wsp_relationstatus_label']}"
],
"IsRead": true
}
-
Change Authentication to "Active Directory OAuth".
-
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.
-
Did you find this page helpful?
Yes No
Sorry about that
Why wasn't this helpful? (check all that apply)
Thank you for your feedback.
Want to tell us more?
Email your feedback to our documentation team.
Great!
Thanks for taking the time to give us some feedback.