{"id":110906,"date":"2018-01-10T05:54:19","date_gmt":"2018-01-10T13:54:19","guid":{"rendered":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/multiple-attachments-single-email\/"},"modified":"2018-01-10T05:54:19","modified_gmt":"2018-01-10T13:54:19","slug":"multiple-attachments-single-email","status":"publish","type":"power-automate","link":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/multiple-attachments-single-email\/","title":{"rendered":"Advanced | Flow of the Week: Send multiple attachments on a single email"},"content":{"rendered":"
Hello, and welcome to another post in the Flow of the Week series. In case, this is the first article you are reading \u2013 Flow of the Week is a series of blog posts, which illustrates use cases and scenarios that can be automated using Microsoft Flow \u2013 so be sure check out other posts in this series.<\/p>\n
Today, we are going to be looking at one of the common asked questions by our customers, sending multiple attachments on a single email. <\/em><\/strong>To illustrate this, we will be creating an item on a SharePoint list and attach a few files to it. Our flow will trigger, on this new item being added. The flow will get all the attachments on the item, construct an array of all the attachments and finally we will use this \u201carray of attachments\u201d and send it out on an email. Let\u2019s dig in to it, shall we?<\/p>\n Let start by adding a trigger \u2013 \u201cWhen an item is created\u201d and selecting the correct SharePoint Site and List.<\/p>\n Please ensure that you already have SP List created that allows storing multiple attachments on the items in it.<\/p>\n <\/p>\n After adding the trigger, we need to fetch all the attachments added to the newly created list item. We should, hence, add the \u201cGet attachments\u201d action. The Site name and List name remain the same from the previous step. We want to then pipe the output \u201cID\u201d from the trigger, to the input \u2018ID\u2019 field.<\/p>\n <\/p>\n Now, that we have a handle on all the attachments \u2013 we must store these in a single array. Let\u2019s start by initializing an array.<\/p>\n <\/p>\n Once the array is initialized, the next step is fetch and store the attachment contents in the array. This is a bit tricky to setup, so be careful to follow the instructions to the T.<\/p>\n <\/p>\n Start by adding a \u201capply to each loop\u201d, then chose the \u201cbody\u201d output from the \u201cGet Attachments\u201d<\/p>\n<\/li>\n Next add \u201cGet attachment content\u201d action inside the loop. The SP site name and list name don\u2019t change.<\/p>\n For the ID field \u2013 select ID output from the \u201cWhen an item is created\u201d trigger<\/p>\n<\/li>\n For the file identifier field \u2013 Select the Id output from the \u201cGet Attachments\u201d action.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n Next, we want to start adding to the array we just initialized. Set it up as shown below<\/p>\n<\/li>\n<\/ul>\n <\/p>\n Let\u2019s revisit what we have setup so far \u2013<\/p>\n For a new item created \u2013 we are first fetching all the attachments that were added to the item.<\/p>\n<\/li>\n The \u201cGet attachments\u201d action returns the file names of the attachment and a corresponding \u201cfile identifier\u201d. It does NOT return the contents of the attachment.<\/p>\n<\/li>\n The attachment content is fetched separately using the \u201cGet attachment content\u201d action.<\/p>\n<\/li>\n Our array, contains the attachment item with two properties \u2013 Name and ContentBytes. We are assigning the DisplayName<\/strong>, retrieved from \u201cGet Attachments\u201d action to the Name<\/em><\/strong> property and the Attachment Content<\/strong>, retrieved from \u201cGet Attachment Contents\u201d action to the ContentBytes<\/em><\/strong> property.<\/p>\n<\/li>\n<\/ul>\n Now for the final step, we need to send the email with the attachments array we just constructed.<\/p>\n This step is straightforward, add an action to send an email \u2013 using your favorite email connector and pipe in the attachmentArray output to the attachments input field.<\/p>\n <\/p>\n That\u2019s it! Once you have successfully created and saved your flow, be sure to test it by exercising the trigger. You should see an email like as shown in your inbox with multiple attachments sent on a single email.<\/p>\n <\/p>\n That’s it for this time. If you have any questions, suggestions or feedback about flow, please feel free to post below in the comments, in our\u00a0community<\/a>, or reach out on Twitter.<\/p>\n","protected":false},"excerpt":{"rendered":" For Flow of the Week, Senior Program Manager, Sunay Vaishnav will show you how to send multiple attachments on a single email using Microsoft Flow. Be sure to read and see how you can automate your business processes using Flow!<\/p>\n","protected":false},"author":131,"featured_media":0,"comment_status":"open","ping_status":"open","template":"","power-automate-category":[2590],"power-automate-tag":[2441,2461,2569,2689,2777],"coauthors":[2134],"class_list":["post-110906","power-automate","type-power-automate","status-publish","hentry","power-automate-category-flow-of-the-week","power-automate-tag-advanced","power-automate-tag-attachments","power-automate-tag-emails","power-automate-tag-multiple","power-automate-tag-sharepoint"],"yoast_head":"\n\n
\n
\n