Blog-Image

Move attachments from D365 to Azure Blob Storage & provide convenient link on Email and Delete Attachments in CRM by using Power Automate

Step 1:
Create a blank Flow template. Choose the Dynamics 365 Connector and trigger as, "When a row is added, modified or deleted".
Select your Organization Name, and the entity, in our case it is Email Messages.
Select Columns is statecode and Filter rows is
If statecode eq 6 and attachmentscount gt 0 (If statecode = 6 and attachmentscount > 0)

PowerAutomate Image

Step 2:
Adding Initialize variable 2 email Status
Select Name as Links and its type is string
Select Name as emailstatus , Type is Integer and value is Status Reason

PowerAutomate Image

Step 3::
Adding Initialize variable for links
Select Name as Links and its type is string
Without adding the value, we didn't get the proper way for Links in CRM Email Body. Because we are adding value for CRM Email Body. By adding <br /> break tag we will get step by step links in Email Body.

PowerAutomate Image

Step 4:
First choose the Microsoft Dataverse then add the List Rows
We can select Attachments for Table Name after that we can filter the row and select Email Message
before that we add _objectid_value eq. email message value.

PowerAutomate Image

Step 5:
1) Create Blob (V2)
2) Create SAS URL by path (V2)
3) Append to string Variable
4) Delete a Row
These 4 steps are involved in the Apply to Each step
In this step we can select the Apply to each and select Value for Output from previous steps
In Apply to each we select value for previous output steps.

PowerAutomate Image

Step 5.1:
First, we can create Azure account with link of our Microsoft Account and Create Azure Blob Storage and create folder in Azure Storage Account.
Add an Action and Select Create Blob (V2)
Add Storage account name or blob endpoint what we create in the Azure Blob Storage Account
Add the folder path name , if we want the links year wise and monthly wise we can add the
int(formatDateTime(utcNow(), 'yyyy')) for the Year
string(formatDateTime(utcNow(), 'MMM')) for the Month
If we add this on folder path, we get year wise and monthly wise links.
Add Blob name is File Name and Blob content is @{base64ToBinary(items('Apply_to_each')?['body'])}

PowerAutomate Image

Step 5.2:
Add Action and Create SAS URI by path (V2)
Add Storage account name or blob endpoint and select
Use connection settings(emailattachments001) , Add Blob Path is Path and in Permissions is Read.

PowerAutomate Image

Step 5.3:
We can Add Append to String Variable
In this select Name as Links and the value for sharing links and showing file name or showing links also
<a href='web Url'>File Name</a><br /> (this show the File Name) "@{outputs('Create_SAS_URI_by_path_(V2)')?['body/WebUrl']}) (Web Url) @{items('Apply_to_each')?['filename']} (File Name)

PowerAutomate Image

Step 5.4:
And the last one we can Delete the Email Attachment in CRM
We can Add the Delete a Row in Microsoft Data verse
In this select Table name as Attachments and we can select Row ID is Activity Mime Attachments in List Rows

PowerAutomate Image

Step 6:
We can Add a condition If the Links are containing https then update

PowerAutomate Image

Step 6.1:
In the first we select Microsoft Data verse and select Update a Row
The Table name is Email Message, Row ID is same as Table name Bcz we are Updating this Table and Row ID and Select Activity Status is Open after that we will go to Advance Option, and Select Status Reason is Draft.

PowerAutomate Image

Step 6.2:
Add Action For Delay for Email message
Add count is What ever you want for delay in Seconds or Minutes or Hour

PowerAutomate Image

Step 6.3:
In the first we select Microsoft Data verse and select Update a Row
The Table name is Email Message, Row ID is same as Table name Bcz we are Updating this Table and Row ID after that we will go to Advance Option, we will get more options. In this Description we can Add Description and Links

PowerAutomate Image

Step 6.4:
In the first we select Microsoft Data verse and select Update a Row
The Table name is Email Message, Row ID is same as Table name Bcz we are Updating this Table and Select Activity Status is Completed after that we will go to Advance Option, and Status Reason is email status.

PowerAutomate Image
quote-image

Move attachments from D365 to Azure Blob Storage & provide convenient link on Email and Delete Attachments in CRM by using Power Automate

Ramesh, Cloud Solution Specialist
We Are IZENIX SOLUTIONS

We Work to Help You Grow

Izenix educate and explain practical performance and configurations for fast check and best outcomes

Implementation
100%
Training
100%
Support
100%
We Are Here For You

Let�s Get Back to Work

Getting a better understanding of Izenix's specialized services and solutions

Schedule for Free Demo
×