Forum Discussion
Manual Trigger File Input Attach to an Email - I have tried everything!
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?
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.'.
- Jennife_rSep 17, 2024Copper Contributor
- michalkornetSep 18, 2024Iron Contributor
Hi Jennife_r, apologies for using the old Designer. To make it cleaner, you can edit your flow to have something like this (with multiple conditions one after another).
1. Add an array variable.
2. Add a condition to check if the attachment is not empty (as you did, but avoid nesting them).
3. Inside each condition, add an "Append to array variable" action.
The structure should look like this:
{
"Name": @{triggerBody()['file']['name']},
"ContentBytes": @{base64ToBinary(triggerBody()['file']['contentBytes'])}
}Use this new variable in the attachments section of the Outlook action.
Please remember to enable the option that allows adding the entire array to the attachments.
The entire flow.