cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
maxtarneberg
Advocate II
Advocate II

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

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

1 ACCEPTED SOLUTION

Accepted Solutions
Gareth1
Resolver IV
Resolver IV

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)

View solution in original post

6 REPLIES 6
Gareth1
Resolver IV
Resolver IV

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)

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

 

 

 

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 

 

Hi @maxtarneberg ,

 

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

1.PNG

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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

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

Helpful resources

Announcements
 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Users online (1,387)