cancel
Showing results for 
Search instead for 
Did you mean: 
trice602

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.

 

trice602_0-1706291471677.png

 

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.

 

trice602_2-1706291756449.png

 

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.

 

 

trice602_1-1706291635554.png

 

 

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.

 

trice602_4-1706292314801.png

 

 

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.

 

trice602_5-1706292505033.png

 

Next, select the dynamic content, shown below.

 

trice602_7-1706292580380.png

 

So, when you flow looks like this, continue.

 

trice602_9-1706292669486.png

 

Next, add the action Initialize variable and name variable "attachments1" and the type is "array", shown below.

 

trice602_10-1706292751276.png

 

 

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.

 

trice602_13-1706293157343.png

 

 

trice602_11-1706292909958.png

 

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.

 

trice602_12-1706293067037.png

 

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.

 

trice602_14-1706293413891.png

 

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.

 

trice602_15-1706293914297.png

 

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.

 

trice602_16-1706294140396.png

 

 

 

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.

 

trice602_17-1706294499817.png

 

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 FlowMicrosoft 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.   

 

trice602_18-1706295007997.png

 

Always glad to help!  Tom

 

 

 

 

Comments

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! 

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?  

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.

 

trice602_0-1714139069042.png

 

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

 

trice602_1-1714139249178.png

 

Always glad to help! Tom 💯💯💯💯💯

Hi @AKA_Faceman ,

 

Nice!  Thanks for the comment!  Always glad to help! Tom 💯💯💯💯💯

Thanks @trice602, for the thorough explanation! 

 

I will try your suggestion and get back on this. 🙂 

About the Author
  • Experienced Consultant with a demonstrated history of working in the information technology and services industry. Skilled in Office 365, Azure, SharePoint Online, PowerShell, Nintex, K2, SharePoint Designer workflow automation, PowerApps, Microsoft Flow, PowerShell, Active Directory, Operating Systems, Networking, and JavaScript. Strong consulting professional with a Bachelor of Engineering (B.E.) focused in Information Technology from Mumbai University.
  • I am a Microsoft Business Applications MVP and a Senior Manager at EY. I am a technology enthusiast and problem solver. I work/speak/blog/Vlog on Microsoft technology, including Office 365, Power Apps, Power Automate, SharePoint, and Teams Etc. I am helping global clients on Power Platform adoption and empowering them with Power Platform possibilities, capabilities, and easiness. I am a leader of the Houston Power Platform User Group and Power Automate community superuser. I love traveling , exploring new places, and meeting people from different cultures.
  • Read more about me and my achievements at: https://ganeshsanapblogs.wordpress.com/about MCT | SharePoint, Microsoft 365 and Power Platform Consultant | Contributor on SharePoint StackExchange, MSFT Techcommunity
  • Encodian Owner / Founder - Ex Microsoft Consulting Services - Architect / Developer - 20 years in SharePoint - PowerPlatform Fan
  • Founder of SKILLFUL SARDINE, a company focused on productivity and the Power Platform. You can find me on LinkedIn: https://linkedin.com/in/manueltgomes and twitter http://twitter.com/manueltgomes. I also write at https://www.manueltgomes.com, so if you want some Power Automate, SharePoint or Power Apps content I'm your guy 🙂
  • I am the Owner/Principal Architect at Don't Pa..Panic Consulting. I've been working in the information technology industry for over 30 years, and have played key roles in several enterprise SharePoint architectural design review, Intranet deployment, application development, and migration projects. I've been a Microsoft Most Valuable Professional (MVP) 15 consecutive years and am also a Microsoft Certified SharePoint Masters (MCSM) since 2013.
  • Big fan of Power Platform technologies and implemented many solutions.
  • Passionate #Programmer #SharePoint #SPFx #M365 #Power Platform| Microsoft MVP | SharePoint StackOverflow, Github, PnP contributor
  • Web site – https://kamdaryash.wordpress.com Youtube channel - https://www.youtube.com/channel/UCM149rFkLNgerSvgDVeYTZQ/