I have a flow that populates a Word doc and converts it into a PDF.
The data comes from SharePoint which gets it from a form submission in PowerApps.
The user also attaches files in PowerApps which will be stored in the SharePoint list.
I need both the converted PDF file as well as the attachments from SharePoint to the sent with the email.
I have searched the web far and wide but only every found one or the other solution but not both. I am able to either attach the PDF file OR the SharePoint files but not both.
Please help! Thank you.
This is my flow for getting the attachments from SharePoint. If anyone can help, I'm happy to expand and upload more screenshots.
Hi @v-litu-msft,
I'd appreciate a bit more help with my attachment error 😉
Or anyone else who might have the solution?
Thank you!
Hi,
I had used your code before but after changing the code to the base64() function, saving the flow, closing it and then going back in to edit, the code is swapped back to this:
Hi @MSSAdmin,
Please use the base64() function to convert the attachment content:
base64(outputs('Get_attachment_content')?['body'])
The PDF file part should use the base64() function to process it.
Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you, dragging the PDF append to array out of the "Apply to each" worked to only attach the one PDF but more than one photo.
Still can't open the attached files though 😞
Hi @MSSAdmin,
Thanks for your reply. The repeated PDF file is caused by you append the PDF file action into a loop, duplicate PDF files depends on the number of attachments files.
Please move the Append to an array action that put PDF file out of the Apply to each action.
Would you mind share screenshots of the Send Email action and Append to array action? I want to know how you configure it, thanks for your time.
Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks, I get the emails fine with attachments.
However, I still cannot open either the pdf nor the jpg files.
Additional problem occurred again as mentioned before:
When I take more than one photo to attach to the form, I get the two photos attached to the email which is correct but I also get two pdf files of the form which is unnecessary.
I only need the filled pdf file once and then however many photo the person attached to the form which could be one or five or less or more.
Hi @MSSAdmin,
Thank you for your patience and explanation of the situation.
The error that Flow save failed with code 'InvalidTemplate' and message 'The template validation failed: 'The action(s) 'Create_file' referenced by 'inputs' in action 'Append_to_array_variable' are not defined in the template.'.' is caused by the action name not correct.
I can see that you have renamed the Create file action, so the expression should be corrected to:
{
"Name": "@{outputs('Create_PDF_file')?['body/Name']}",
"ContentBytes": "@{base64(outputs('Convert_Word_Document_to_PDF')?['body'])}"
}
The reason for the file has been damaged is caused by the send Email action only accept base64 format, so we should force the contents of the file to base64 code in case some file content isn't.
Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I'm getting the following error message when doing that:
Flow save failed with code 'InvalidTemplate' and message 'The template validation failed: 'The action(s) 'Create_file' referenced by 'inputs' in action 'Append_to_array_variable' are not defined in the template.'.'.
Honestly I'm losing my mind over this whole thing. I have tried for several hours almost non-stop to find a solution and all I get is more problems.
I have two flows that are the same, they just get content from two different form submissions in PowerApps/SharePoint. Therefore I copy/pasted one flow and adjusted what was needed for the other
(i.e. SharePoint list name etc).
However they both act differently.
While one doesn't give me any attachments at all, the other one worked a few hours ago but with corrupt attachments and now I'm not even getting an email sent.
This whole time though, the flow works fine. I don't get error messages, only the green "Your flow ran successfully".
Hi @MSSAdmin,
You could refer to my first reply, use the base64() function convert the file content into base64 code, and try it again:
{
"Name": "@{outputs('Create_file')?['body/Name']}",
"ContentBytes": "@{base64(outputs('Convert_Word_Document_to_PDF')?['body'])}"
}
Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I have another question:
When trying to attach more than 1 picture as an attachment, I get sent an email and there are two problems with it:
1) I get sent the two pictures I attached (as it should) but also the filled in PDF twice.
2) I can't open the pictures nor the pdfs that are attached.
The error message for the pdf file is:
Adobe Acrobat Reader could not open 'Draft - Hrunf[2].pdf' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded).
The error message for the photo is:
The file “2E4B625D-218F-4615-AB41-DAC574185066[1].jpg” could not be opened. It may be damaged or use a file format that Preview doesn’t recognise.
Any suggestions on why that happens?
Michael E. Gernaey
497
Super User 2025 Season 2
David_MA
436
Super User 2025 Season 2
Riyaz_riz11
244
Super User 2025 Season 2