Send Microsoft Form Attachments to an Email - End to End Walkthrough
One of the FAQs I see a lot is how to send Microsoft Form attachments to email and, in this walkthrough, we will go through every step with no steps skipped so you can do this yourself!
Here, I have a sample form with just two questions: Name and File Upload. In my example, the end-user can upload more than one file at a time - up to three to be specific. Here's the Microsoft Form.
So, once you have a Microsoft Form created, let's start building your flow.
The first step is to start creating a new automated power automate flow.
At make.powerautomate.com, click on Create, then select Automated Cloud Flow, then name your flow and select the trigger, "When a new response is submitted", then click on the Create button. Again, in the context of "no steps skipped", this is the automated trigger that will start the flow every time someone fills out your form.
Next, we need to configure the trigger by pointing to the Microsoft Form we just created. You will select this by name. Mine is called "Form with Attachment to Email", shown below.
Next, add your first action "Get response details" and configure as shown below. Here we are telling our automation when the flow starts, we want to get the form responses so we can use the submitted responses downstream in our flow. Select the form and then add the dynamic content Response ID from the trigger. In short, this links this action to the trigger, so think of it this way: when a new form response is submitted, get the form responses.
To add dynamic content, click on the field ResponseID then click on the lightning bolt that appears to the right of the field. You can also type "/" to open up the dropdown menu options too - both do the same thing.
Next, select the dynamic content, shown below.
So, when you flow looks like this, continue.
Next, add the action Initialize variable and name variable "attachments1" and the type is "array", shown below.
Ok, so at this point we are moving right along and ready to get some Form results so we can keep building the flow. Click on test in the top right and select manual and click on test button. Then fill out the form and add your name plus upload three sample files, shown below.
When you test flow runs, click on the action Get response details and look at the output. We are specifically looking for the JSON output from the question "Add a file", shown above. You want to copy the entire JSON string as shown below.
Next, add the action Parse JSON and in the Content field select the dynamic content (by putting your cursor in the field and selecting the lightning bolt or typing "/" and select "add a file" under the category Get response details. When you do that, your dynamic content may appear as something different such as body/r95456541236556, shown below.
The last step is to click on the link "Use sample payload to generate schema". Then we will paste in our copied JSON (the previous step) and paste it in and click Done. Your screen should like similar to the one shown below.
Next, add the action Get file content, shown below. Then add the dynamic content ID from your Parse JSON action. Notice when you do that, it will put this action in an apply to each (or for each) loop and that's because... for each attachment uploaded (remember, my form can have up to three in a single question), loop through each file and get the file content for each. So in my example here, because I uploaded 3 files, we will loop through this 3 times.
Next, the last step inside the apply to each (or for each) loop is add the action Append to array variable, shown below. Select the variable "attachments1" from the dropdown and type in the value exactly as it is shown below. Be sure to add the curly brackets at the beginning and the end and add the space after each such as "Name":
Select the dynamic content from Parse JSON and get the Name of the file and for ContentBytes, use the dynamic content from Get File content.
So be sure to add the curly brackets, the double quotes, semicolons, and the comma. You screen should look exactly like mine above.
Outside of the apply to each (or for each) loop, add the action Send Email V2 and configure as shown below. In the attachment item field, add the variable attachment1 as dynamic content.
Save and test. Notice below, my apply to each (or for each) loop ran through the loop 3 times, because we uploaded 3 files in the example.
Microsoft Form Attachments to Email - Complete Flow
In summary, you just learned one of the FAQs here - "How to Send Microsoft Form Attachments to an Email"! You learned about using a variable, appending a variable, parsing a JSON value from a form and using/accessing the values downstream, and sending all the attachments in a single email! Goes without saying, that was fun! #neverstoplearning #sharingiscaring #powerautomate #walkthroughs
My name is Thomas Rice (aka trice602) and if you have worked with me in the past, you know my email signature is "Always glad to help!". I hope you enjoyed this walkthrough.
Always glad to help! Tom ⭐⭐⭐⭐⭐
Comments
-
Send Microsoft Form Attachments to an Email - End to End Walkthrough
Thanks for the guide, but I have an issue. I converted the form to PDF and attached it to the email, but how do I also attach the original attachments from the form
-
Send Microsoft Form Attachments to an Email - End to End Walkthrough
Great to hear @willemvandooren ! Always glad to help! Tom
-
Send Microsoft Form Attachments to an Email - End to End Walkthrough
Hi @trice602,
Just wanted to let you know that everything works perfect now! Thanks again for your explanation!
In the end I even needed to conditional statements after each other, because we have two separate upload fields in our ms form. Maybe not the most elegant solution, but it works. 😄
Also at the end there is a switch condition which is based a choice the respondent makes in the form. Dependent on that, it will e-mail the responses to a certain email address.
Have a nice weekend!
-
Send Microsoft Form Attachments to an Email - End to End Walkthrough
-
Send Microsoft Form Attachments to an Email - End to End Walkthrough
Hi @willemvandooren ,
Thanks for checking this out and asking. Yes, in this example, even though the form upload question was not required, because the entire form is for the upload, the flow doesn't handle optional uploads.
To add that, you simply add everything from the parse json action into a conditional action and check if the question is blank first.
After I add my condition, I drag everything from parse json to send email into the true side of the condition. Then I check if the value of the question is empty by using the empty expression:
empty(dynamic upload question content)
is not equal to
true expression
Always glad to help! Tom 💯💯💯💯💯
-
Send Microsoft Form Attachments to an Email - End to End Walkthrough
Nice tutorial, the steps are all clear. But in this flow an upload file is required right? Because I was testing my flow, but when you don't upload a file the flow fails. How to handle null values in this case, for instance for upload fields which aren't required?
-
Send Microsoft Form Attachments to an Email - End to End Walkthrough
Hi,
Thanks for the above - I found it really easy to follow.
It's helped me sort an issue that I have had for ages where PDF's were corrupted when I tried to send them from a form!
Thankyou!
*This post is locked for comments