cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
KhrisJones
New Member

Power Automate - Multiple files from Onedrive to email attachment

Hi, I have flows set up to save attachments from emails to a onedrive for business folder - This works OK.

 

I then have a flow set up to check the count of files in the folder and if 2 or more, attach those files to an email, send and then delete the source files. This flow runs without error however the file content being sent/received is incorrect. 

 

The input data is .txt or .csv files and contains data like:

KhrisJones_0-1632230552448.png

however the data being received over email (With the right filenames) has data like:

KhrisJones_1-1632230620008.png

My flow is set up to trigger when a file is saved, list files in folder, for each file increase the value of a Integer variable, then i initialise an array variable, then do a check on the integer variable and if greater than or equal to 2 it proceeds to this step:

KhrisJones_2-1632230777104.png

 

Then the email that is sent has the allattach variable listed in the attachements section:

KhrisJones_3-1632230818078.png

 

Ive tried searching a number of other posts/questions/guides however everything i can find is using Sharepoint instead of onedrive and the actions are subtlety different. 

 

Any help is appreciated,

 

Thanks,

Khris

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
eric-cheng
Solution Sage
Solution Sage

Hi @KhrisJones ,

 

In your append to array action, can you please check you are referencing the correct value for ContentBytes?  I believe it should be File Content from Get File Content 2.

--------------------------------------------------------------------------
If I have answered your question, please mark my post as a solution
If you have found my response helpful, please give it a thumbs up

Connect on LinkedIn

View solution in original post

4 REPLIES 4
eric-cheng
Solution Sage
Solution Sage

Hi @KhrisJones ,

 

In your append to array action, can you please check you are referencing the correct value for ContentBytes?  I believe it should be File Content from Get File Content 2.

--------------------------------------------------------------------------
If I have answered your question, please mark my post as a solution
If you have found my response helpful, please give it a thumbs up

Connect on LinkedIn

View solution in original post

DamoBird365
Super User
Super User

@KhrisJones 

 

You need to check the dynamic value that you have used for file content.  It is returning a JSON array of the body - you specifically want file content from the get file content action.

 

Here is an alternative solution for you to explore too:

 

DamoBird365_0-1632231837971.png

 

Expressions are highlighted in comments.  You can use length() to get the length or number of objects (i.e. files) returned in an array.  Then get the file content in an apply to each and create a compose for each attachment.

 

DamoBird365_1-1632231879124.png

 

Outside of the Apply to each, call the compose actions into an array using outputs() and place that into your email.

 

You will not need to use variables and hopefully have a more efficient solution.

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here and like & subscribe to my YouTube Channel thanks 😉

 

Thanks Eric-Cheng - Im not entirely sure why i had it set up as body, I was following a how to guide but as you have written, its quite obvious now to think it should be the File Content from their. Probably due to the guides i was looking at referencing SharePoint and adding it in this way (Name and then Body).

 

I have changed this and it ran successfully first time, thank you for highlighting that so quickly!

Thanks DamoBird365 - Absolutely right in that i need to use the File Content, i was following guides for Sharepoint and they say about using the array and the name + Body but its so obvious now we have mentioned it. 

 

It works now using the file content but i will digest what you have said and hopefully give that a try to see the outcome if it would be a more efficient solution.

 

Thanks again,

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (2,983)