I'm trying to set up an instant cloud flow that I can trigger from a SharePoint List item which allows the user to input text and attach a file that will be dropped into an email generated during an action later in the flow. The issue I'm having is that the file provided during input is not being attached to the email in the correct format.
Here's a rundown of my flow:
Triggered from a selected SharePoint List item:
Get item action to retrieve data from the list to populate on the email
Send email action to populate an email with information from the List item and inputs from the trigger:
Text input from the trigger goes into the body
File Content input from the trigger goes in the Attachments
The flow is populating the Text input into the email body fine, but the attachment is coming through in an unknown file format and the name doesn't match the inputted file on the trigger:
I don't see any other Dynamic Content selections to choose from that would populate the attachment. Is there some addition action I need to do prior to the Email action to convert the file into an attachable format?
I came to this post hoping to find an answer - but through some trial and error, I figured it out so I'll share...
The dynamic content from the instant flow trigger isn't available in the dynamic content list so you need to manually type it into the expression builder. Look at the raw output of the trigger:
Item 1 has the trigger inputs, the text and file fields. Item 2 has the list item fields which are available in the dynamic content dropdown and so, like me, you may have assumed fileName was the name of the file you're trying to attach but it is actually the name of the list item/'selected item'.
You should use instead:
file name: triggerBody()?['file']?['name']
file content: triggerBody()?['file']?['contentBytes']
So my scenario is a bit different than the one linked here. I'm not actually calling up an existing file that is already stored other on the List item or within a SharePoint document library, the file is being added by the user when the flow is being triggered:
The user is importing a local file as an input and I'm just trying to get that file attached to the email being sent by the flow.