web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Power Automate - Multi...
Power Automate
Answered

Power Automate - Multiple files from Onedrive to email attachment

(0) ShareShare
ReportReport
Posted on by 9

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

 

 

 

Categories:
I have the same question (0)
  • Verified answer
    eric-cheng Profile Picture
    5,171 on at

    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

  • DamoBird365 Profile Picture
    8,942 Microsoft Employee on at

    @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 😉

     

  • KhrisJones Profile Picture
    9 on at

    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!

  • KhrisJones Profile Picture
    9 on at

    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,

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 262 Super User 2026 Season 1

#2
Haque Profile Picture

Haque 227

#3
Expiscornovus Profile Picture

Expiscornovus 225 Most Valuable Professional

Last 30 days Overall leaderboard