So I am here again, back with another blog on Power Automate and this time with a requirement which is quite common . And why not? After all with Power Automate, connecting multiple line of business systems have become really easy.
So what I am going to discuss here? Precisely this blog will touch on the following requirements.
- How to retrieve attachment from Notes in Dynamics 365/ CDS and send all attachments in a single email using Microsoft Flow/ Power Automate?
- How to attach multiple documents from SharePoint into an email and send it using Microsoft Flow/ Power Automate?
Here I am going to explain with the CDS and Notes but the same applies if you are getting the attachments from SharePoint or for that matter any other data source. The process remains the same.
So I have an account record and there are couple of notes with attachments.
Using flow we will combine these attachments and send it using a single email. Let’s see how we can do this.
I have created an instant workflow and use the List Records step of Common data service to get all the notes related to the account in question. Here I have hardcode the account GUID. But in real time you can put it to dynamic as well.
Next I declare a variable of type Array. This variable will be used to store all attachments for all the notes related to the account.
Now the most important step. I will iterate through the notes and add the attachments to the array variable declared in earlier step.
What am I doing here? Observe the JSON string I am preparing while appending each attachment to the Array variable. You might be wondering – “Can’t we just append the content to the array variable?”. The answer is “Yes we can”. But the issue with it is once the email is sent and the user want to open the attachment from the emails, it won’t open.
This is because although the content is there, the content type is not present. Hence to get it working properly, we need to specify not only the content but the content type.
So that’s it. Now the final step is to send the email with all the attachments.
And I get the below email.
Hope this helped!
You may also like the below posts.
Debajit Dutta
Business Solutions MVP
Discover more from Debajit's Power Apps & Dynamics 365 Blog
Subscribe to get the latest posts sent to your email.