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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Find files in Sharepoi...
Power Automate
Answered

Find files in Sharepoint based on filename contains dynamic content and attach to email

(0) ShareShare
ReportReport
Posted on by 116

Hi There,

 

I have a folder on Sharepoint with hundreds of photos. They all have a unique flow created filename with SiteName-SerialNo-Product-DateTime.jpg

 

I have a flow already in place that is triggered from a button on a row item on a Sharepoint list. It creates a spreadsheet containing SiteName, SerialNo, Product etc that is attached to an email.

 

How can I make a flow that finds the photo files, based on dynamic content from current flow, where filename contains SiteName, SerialNo etc, then is able to attach them to the email along with my spreadsheet?

 

Any help greatly appreciated

Max

Categories:
I have the same question (0)
  • Verified answer
    Gareth1 Profile Picture
    308 on at

    Hi @maxtarneberg 

     

    There are a couple of ways of doing this one would be to use the concat expression to build up the file name, then using the Get Files (properties only) return all the files then filter the array

    Screen Shot 2020-01-08 at 7.07.56 pm.png

     

    Once you have filtered the files based on the name you could loop through the files and add them to an attachment array and use the attachment array to add the attachments to the email

    Screen Shot 2020-01-08 at 7.08.42 pm.png

    A simpler way to do this would depend on if all of the files have the same file type / extension then you could just use the Get Files by path (but you would also need the date field and extension of the file)

  • maxtarneberg Profile Picture
    116 on at

    Hi @Gareth1,

     

    Thank you for your help. This seems to be the right path for my purpose.

     

    However, I'm having a little trouble in fully realising your solution, would you be able to expand please?

     

    In particular, I'm having trouble with the Append the Array Variable stage:

    {

    "Name": "Items(...)",

    "ContentBytes": "Base64(...)"

    }

     

    What is the code between these brackets for Items and Base64?

     

    Thank you for your patience, I am not an experienced programmer or flow writer

     

     

     

  • Gareth1 Profile Picture
    308 on at

    Hi @maxtarneberg 

     

    Hopefully this helps

     

    Screen Shot 2020-01-09 at 8.58.54 am.png

     

    This process will pickup any files that meet the filename condition, so this process should work for single files as well as multiple files.

     

    If you need anymore help please let me know 

  • v-bacao-msft Profile Picture
    on at

     

    Hi @maxtarneberg ,

     

    When configuring the value of ContentBytes, use the following expression:

    1.PNG

     

    Best Regards,

  • maxtarneberg Profile Picture
    116 on at

    Hi @v-bacao-msft and @Gareth1 ,

     

    Thank you for help so far.

    Unfortunately using both of those expressions you provided did not yield an attachment to my email, though the flow runs successfully, I am just getting email subject and body.

     

    I am now wondering if I am not able to get the flow to find the files in the first place. But I must be close now, hopefully!

    Please see below:

     

    Initially I am creating a dynamic string value which will be present within all file names

    Untitled5.pngUntitled6.png

  • maxtarneberg Profile Picture
    116 on at

    Hi @Gareth1 and @v-bacao-msft,

     

    With ALOT of fiddling, failures, and adjusting various parts of the flow I have eventually got this to work so thank you very much for your helpful input on this.

     

    In the end, at the 'Filter Array' stage I was using a concat String which would be contained within the filename. But I used the GUID  at the start of the filename (duh!) to filter based on 'starts with' instead, and it now finds the correct files to add to my attachment array.

     

    Thanks again and happy flowing 

    Max

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard