Hello,
I am trying to create a PDF attachment that includes form responses. I am using 'When a new response is submitted...', 'Apply to each','Get response details', 'create file', 'get file content', and 'send an email (V2)'.
The flow works properly and displays as a PDF attachment both on the e-mail and in my SharePoint site, however, the file is corrupt and will not allow me to view. The only error I can seem to find is that the 'Attachment Content' changes the "ContentBytes" to 'Body' after I save my flow, and does not keep 'Get File Contents'.
Does anyone have solution to this?
Thank you!!!
CJ
I also noticed "File Content" kept switching to "Body".
In my case, the pdf file is fine, it's just that I can't preview the PDF in Outlook (gives me error). I have to double click to open it in Edge or Chrome to see the content.
A different use case (invoice approvals generating an email with the approved invoice attached to the email), but same issue: "File Content" switching to "Body" in the "Attachment Content" field every time I save the flow. As such, the attachment in the tested or run flow will be a corrupted, unopenable file (regardless of file type) both for the initial approval notification and for the approval email attachment.
I can't find any way to get the "File Content" to stick and not switch to "Body" and thus can't get my attachments into my flow. No idea what is going on.
THANK YOU! You were a magnificent help!!
Hi @cjp18
Yes 😉 the last action can be replaced with a create item on SharePoint instead of OneDrive. The original html file will need to be created on OneDrive but the PDF can be created on SharePoint. You might also want to delete the original HTML file on your OneDrive afterwards too with the delete file action.
If you've got any more questions please let me know. I hope this helps.
Ali B
Ali B - This solution worked! Thank you so much! Is there any way with utilizing the OneDrive for Business to get these files to save in the SharePoint site rather than my personal OneDrive?
Hi @cjp18
If you want to create a PDF, you need to first create an html file. Then you can convert the html to PDF using the OneDrive convert file action. Using the following HTML as an example W3Schools Tryit Editor, we can save that into a compose (you could of course add in your dynamic content from the forms response). You then create an html file using that content, you can then convert it to PDF and then you take the content from that action to create a new PDF file.
If you've got any more questions please let me know. I hope this helps.
Ali B
Michael E. Gernaey
566
Super User 2025 Season 1
David_MA
516
Super User 2025 Season 1
stampcoin
492