Send Grid Connector - Send Email (Multiple Attachments)
Published Sep 07 2021 01:36 AM 4,169 Views

In the scenario when we have a logic app with O365 Trigger - when a new email arrives, and the email comes with multiple attachments; there is a current limitation in Send Grid connector -Send Email V4; where we cannot use the attachments array to send the received attachments all at once in one email.


The below logic app shows the limitation scenario:



If we used the above structure, the send grid action will fail with the below error:

  "error": {
    "message""Parameter \"Content\" should be provided",


The reason the action fails; is due to the direct mapping from the O365 attachment array to the send grid attachments array; which has a difference in parameter names; such as Content.


For Send Grid Connector - Send email (V4); we can manually add the attachments using the individual attachment form; as below:



But this will cause each attachment to be sent in a separate email (due to the for each); which is not the desired target of the logic app.


By looking into code view, of the attachment array structure; when adding the attachment manually; we find it to be in the below structure:

 "attachments": [
So, the work around for this limitation, is to build the above attachments array within the logic app, and pass it as an attachment array to the Send Grid action; as below:

Note: The attachment content from the dynamic content is "@{base64ToString(items('For_each')?['contentBytes'])}"; using it like this causes the send grid action to fail with error:

                "message""The attachment content must be base64 encoded.",
So, we need to switch to Code view, and update the Append Array action to have the below body (we removed the base64ToString expression) :


Also, the For Each parallelism need to be set to 1; in order to avoid incorrect variable assignments.


After having the array ready, we can pass it directly to the send grid action as below:



Below is the Full Logic App structure:



By this, we can send all received attachment (from the O365) to the Send Grid action; in one execution.




Version history
Last update:
‎Sep 07 2021 01:36 AM
Updated by: