{"id":656,"date":"2020-10-24T12:15:11","date_gmt":"2020-10-24T16:15:11","guid":{"rendered":"https:\/\/www.dontpapanic.com\/blog\/?p=656"},"modified":"2020-10-24T12:16:06","modified_gmt":"2020-10-24T16:16:06","slug":"emailing-file-attachments-from-forms-with-power-automate","status":"publish","type":"post","link":"https:\/\/www.dontpapanic.com\/blog\/?p=656","title":{"rendered":"Emailing File Attachments from Forms with Power Automate"},"content":{"rendered":"<p align=\"left\"><a href=\"https:\/\/www.dontpapanic.com\/blog\/wp-content\/uploads\/2020\/10\/Forms.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"176\" height=\"176\" title=\"Forms\" align=\"left\" style=\"margin: 0px 0px 10px; float: left; display: inline; background-image: none;\" alt=\"Forms\" src=\"https:\/\/www.dontpapanic.com\/blog\/wp-content\/uploads\/2020\/10\/Forms_thumb.jpg\" border=\"0\"><\/a> <a href=\"https:\/\/www.dontpapanic.com\/blog\/wp-content\/uploads\/2020\/10\/Flow.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"176\" height=\"176\" title=\"Flow\" align=\"left\" style=\"margin: 0px 10px 10px 0px; float: left; display: inline; background-image: none;\" alt=\"Flow\" src=\"https:\/\/www.dontpapanic.com\/blog\/wp-content\/uploads\/2020\/10\/Flow_thumb.jpg\" border=\"0\"><\/a>I\u2019ve seen some questions recently on the Power Platform Forums about how to send multiple attachments submitted in Microsoft Forms in an email.&nbsp; Since this seems to be a common problem I thought it would be good to walk through the steps in a BLOG post.<\/p>\n<ol>\n<li>\n<div align=\"left\">Once you have a Microsoft Form created that includes a question with an attachment you can create a new Power Automate Flow that uses the \u201cWhen a new response is submitted\u201d trigger.&nbsp; That will start your flow each time a response is submitted through Microsoft Forms. But the trigger alone won\u2019t provide enough detail about what is in the response.&nbsp; So you also need to add a \u201cGet response details\u201d action to retrieve the questions and the answers submitted in the form.<br \/><a href=\"https:\/\/www.dontpapanic.com\/blog\/wp-content\/uploads\/2020\/10\/Get-Form-Details.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" width=\"644\" height=\"316\" title=\"Get Form Details\" style=\"display: inline; background-image: none;\" alt=\"Get Form Details\" src=\"https:\/\/www.dontpapanic.com\/blog\/wp-content\/uploads\/2020\/10\/Get-Form-Details_thumb.png\" border=\"0\"><\/a><\/div>\n<\/li>\n<li>\n<div align=\"left\">In order to submit more than one file attachment to the email you will need to create an array to hold the name and content of each file.&nbsp; To do this we \u201cInitialize a variable\u201d of type array.&nbsp; We will supply values for the array later in an \u201cApply to each\u201d loop.<br \/><a href=\"https:\/\/www.dontpapanic.com\/blog\/wp-content\/uploads\/2020\/10\/InitFileArray-1.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" width=\"644\" height=\"203\" title=\"InitFileArray\" style=\"display: inline; background-image: none;\" alt=\"InitFileArray\" src=\"https:\/\/www.dontpapanic.com\/blog\/wp-content\/uploads\/2020\/10\/InitFileArray_thumb-1.png\" border=\"0\"><\/a><\/div>\n<\/li>\n<li>\n<div align=\"left\">Now you are ready to retrieve the details of the files attached to the question in the response and add them to the array.&nbsp; To do that you need to use \u201cParse JSON\u201d to parse the contents of the question in the response where the files were uploaded. Run your flow once at this point to get some sample output that you can use to generate the JSON schema.&nbsp; Then add your question content to the Parse JSON.<br \/><a href=\"https:\/\/www.dontpapanic.com\/blog\/wp-content\/uploads\/2020\/10\/parsejson-1.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" width=\"644\" height=\"360\" title=\"parsejson\" style=\"display: inline; background-image: none;\" alt=\"parsejson\" src=\"https:\/\/www.dontpapanic.com\/blog\/wp-content\/uploads\/2020\/10\/parsejson_thumb-1.png\" border=\"0\"><\/a><\/div>\n<\/li>\n<li>\n<div align=\"left\">Files uploaded to a Microsoft Form are automatically stored in the Form creator\u2019s OneDrive for Business account.&nbsp; So now that we have access to the details of those files from the Parse JSON action we can retrieve the file content from OneDrive and append it to the Array we created in Step #2.&nbsp; We\u2019ll use the file id to retrieve the file and then add the Name of the file and the File content to the array. Whether there is one file or multiple files the details will be in an array, so we\u2019ll need to use an \u201cApply to each\u201d loop to get each file and append it. The File content can ge used directly as we retrieve it from OneDrive.&nbsp; No translation to Base64 is required because the file is retrieved as JSON, not binary.<br \/><a href=\"https:\/\/www.dontpapanic.com\/blog\/wp-content\/uploads\/2020\/10\/AppendToArray-1.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" width=\"488\" height=\"484\" title=\"AppendToArray\" style=\"display: inline; background-image: none;\" alt=\"AppendToArray\" src=\"https:\/\/www.dontpapanic.com\/blog\/wp-content\/uploads\/2020\/10\/AppendToArray_thumb-1.png\" border=\"0\"><\/a><\/div>\n<\/li>\n<li>\n<div align=\"left\">Now that we have the file content in an array we can send the email.&nbsp; Be sure to click on the selector in the attachments section to switch from <em>detail inputs<\/em> to an <em>array item<\/em>.&nbsp; Then just fill out the email and add the array variable to the Attachments field.<br \/><a href=\"https:\/\/www.dontpapanic.com\/blog\/wp-content\/uploads\/2020\/10\/SendEmailAttachments-1.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" width=\"564\" height=\"483\" title=\"SendEmailAttachments\" style=\"display: inline; background-image: none;\" alt=\"SendEmailAttachments\" src=\"https:\/\/www.dontpapanic.com\/blog\/wp-content\/uploads\/2020\/10\/SendEmailAttachments_thumb-1.png\" border=\"0\"><\/a><\/div>\n<\/li>\n<\/ol>\n<p align=\"left\">Now you can save and test your flow by filling out the Microsoft Form and uploading one or more attachments to the form.&nbsp; In under 5 minutes you should get an email with the attachments from the form.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I\u2019ve seen some questions recently on the Power Platform Forums about how to send multiple attachments submitted in Microsoft Forms in an email.&nbsp; Since this seems to be a common problem I thought it would be good to walk through the steps in a BLOG post. Once you have a Microsoft Form created that includes &hellip; <a href=\"https:\/\/www.dontpapanic.com\/blog\/?p=656\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Emailing File Attachments from Forms with Power Automate<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[112,118,113,116],"tags":[119,115],"class_list":["post-656","post","type-post","status-publish","format-standard","hentry","category-flow","category-microsoft-forms","category-ms-forms","category-power-automate","tag-microsoft-forms","tag-power-automate"],"_links":{"self":[{"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/656","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=656"}],"version-history":[{"count":2,"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/656\/revisions"}],"predecessor-version":[{"id":666,"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/656\/revisions\/666"}],"wp:attachment":[{"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=656"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=656"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=656"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}