cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MTrummer
Frequent Visitor

Sending multiple attachments with D365 notes attachment does not work

I want to use Power Automate to send attachments from an entity stored within D365 CRM.

I am iterating over the "notes" entity and I send a single e-mail for each attachment for testing purposes.

MTrummer_0-1604791415713.png

 

The test mail contains the attachment which can be opened without any problem.

MTrummer_1-1604791443361.png

 

Later within the flow I use the array to send all attachments in one single e-mail.

MTrummer_2-1604791474557.png

 

Now the issue is that the attachments cannot be opened any more.

They differ in the file size (see 413KB versus 743KB).

MTrummer_3-1604791493220.png

 

How do I fill the ContentBytes attribute of the array properly??

 

I used 

  • base64ToBinary(items('Apply_to_each')?['documentbody'])
  • base64(items('Apply_to_each')?['documentbody'])
  • base64ToString(items('Apply_to_each')?['documentbody'])
  • items('Apply_to_each')?['documentbody']
  • decodeBase64(items('Apply_to_each')?['documentbody'])

but without any success.

1 ACCEPTED SOLUTION

Accepted Solutions
Paulie78
Super User III
Super User III

I believe your problem comes not from the ContentBytes attribute, but from the lack of $content-type disposition. Take a look at this blog post I wrote (which is relevant to attachments in arrays for approvals and regular emails).

https://www.tachytelic.net/2020/09/power-automate-add-multiple-attachments-approval-email/ 

When you add the content type disposition, I think your attachment array will be fine. 

 

Please...

If I answered your question Accept it as a solution ✔️ 

If I helped you out, please give me some Kudos 👍

Thanks 😙

View solution in original post

2 REPLIES 2
Paulie78
Super User III
Super User III

I believe your problem comes not from the ContentBytes attribute, but from the lack of $content-type disposition. Take a look at this blog post I wrote (which is relevant to attachments in arrays for approvals and regular emails).

https://www.tachytelic.net/2020/09/power-automate-add-multiple-attachments-approval-email/ 

When you add the content type disposition, I think your attachment array will be fine. 

 

Please...

If I answered your question Accept it as a solution ✔️ 

If I helped you out, please give me some Kudos 👍

Thanks 😙

View solution in original post

You've made my day.

It works using

{
    "inputs": {
        "name": "AllAttachments",
        "value": {
            "ContentBytes": {
                "$content-type": "@{items('Apply_to_each')?['mimetype']}",
                "$content": "@{items('Apply_to_each')?['documentbody']}"
            },
            "Name": "@items('Apply_to_each')?['filename']"
        }
    }
}

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Users online (68,493)