Forum Discussion
Manual Trigger File Input Attach to an Email - I have tried everything!
Hi Jennife_r,
It’s not so straightforward.
you are right in the old editor, I can see that the additional file name is not available in the Dynamic Content list.
However, you can still access it using the following code:
triggerBody()['file']['name']
Of course, you’ll need to double-check the correct 'file' reference in your case.
The content can be accessed similarly, but to ensure it’s in the correct format, you’ll need to convert it to binary using this function:
base64ToBinary(triggerBody()['file']['contentBytes'])
And just in case, I’m sending the page with information on how to handle SharePoint files so they can be attached correctly: https://learn.microsoft.com/en-us/microsoft-365/community/power-automate-send-sharepoint-files-as-attachments
- Jennife_rSep 17, 2024Copper ContributorHi - appreciate your response but I haven't been able to get anywhere still.
I am able to attach SharePoint files without a problem.
The issue is attaching the files uploaded during the flow using the "File Input" option for the trigger.
I can get the file to appear in the email but it will not open. What am I missing?- michalkornetSep 17, 2024Iron Contributor
Hi Jennife_r ,
My trigger looks like this:
try filling the Outlook action using dynamic content and the following expressions:
The effect should be correct:
I hope this method works in your flow. In case of any problem with the flow do not hesitate to write, we will find a solution.
- Jennife_rSep 17, 2024Copper Contributor
Thank you michalkornet
Before getting your response I was able to make it work by using the New Editor dynamic content "File #1 contentBytes", etc. (which FYI for others - is only offered in "Switch to detail inputs for array items" and is not offered if in "Switch to input entire array" mode). I also tried what you suggested and it also worked - it did not seem to make a difference either way.
But I am still having an issue. I need to attach up to 4 files. Often the user will only have 1 or 2 additional files to attach. So now the flow fails if all 4 file inputs are not used. Please note - it does not fail at the trigger, it will allow you to only upload 2. The flow fails at the Send an Email (vs) action because the attachment is blank.
Is there anyway to push the flow through if only 2 of the 4 inputs are used?
Unable to process template language expressions in action 'Send_an_email_(V2)' inputs at line '0' and column '0': 'The template language expression 'base64ToBinary(triggerBody()?['file_2']['contentBytes'])' cannot be evaluated because property 'contentBytes' cannot be selected. Please see https://aka.ms/logicexpressions for usage details.'.