cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PA-Jimmy
Regular Visitor

Flow to match and group files in a SP library and then send to listed email

Hello,

I have been having the hardest time with this flow. I am looking to make a button start flow that looks in a share point library with a bunch files.

 

each file has a listed email address. I would like the flow to grab all files for each listed email, group them and attach them into the listed email  and send.

 

im able to make flows that are grabbing all attachments and sending them to every listed email. Instead of sending each set of attachments to the specific email.

 

thank you so much everyone! I have searched so much and not able to figure this out.

1 ACCEPTED SOLUTION

Accepted Solutions
v-xiaochen-msft
Community Support
Community Support

Hi @PA-Jimmy ,

 

I made a sample for you.

 

There are the following files in the library, and there is a column of text that is the email address to which the file is sent.

vxiaochenmsft_0-1669712777335.png

 

 

Create a flow, and I will explain it step by step.

vxiaochenmsft_1-1669712777337.png

 

 

Gets the properties of the files in the library.

vxiaochenmsft_2-1669712777346.png

 

 

Select column ‘email address’ data.

vxiaochenmsft_3-1669712777347.png

 

 

Create an array and save only one email address for the same email address.

union(body(‘Select’),body(‘Select’))

vxiaochenmsft_4-1669712777348.png

 

 

Create an empty array.

vxiaochenmsft_5-1669712777348.png

 

 

Add 'Apply to each' to get the properties of the files in the library and filter the same data as the current email address.

Items(‘Apply to each’)?[‘Email’]

vxiaochenmsft_6-1669712777353.png

 

 

Based on the results of the ‘Filter array’, create another 'Apply to each'. Get the file contents based on the path.

items('Apply_to_each_2')['{FullPath}']

vxiaochenmsft_7-1669712777354.png

 

 

Append the following to the empty array.

{"Name": items('Apply_to_each_2')['{FilenameWithExtension}'],

"ContentBytes": body('Get_file_content_using_path')}

vxiaochenmsft_8-1669712777355.png

 

 

Send email with array 'varFile' attached. Finally, set the array to empty.

Items(‘Apply_to_each’)?[‘Email’]

vxiaochenmsft_9-1669712777358.png

 

 

Save flow and run it.

vxiaochenmsft_10-1669712777359.png

 

Best Regards,

Wearsky

View solution in original post

2 REPLIES 2
v-xiaochen-msft
Community Support
Community Support

Hi @PA-Jimmy ,

 

I made a sample for you.

 

There are the following files in the library, and there is a column of text that is the email address to which the file is sent.

vxiaochenmsft_0-1669712777335.png

 

 

Create a flow, and I will explain it step by step.

vxiaochenmsft_1-1669712777337.png

 

 

Gets the properties of the files in the library.

vxiaochenmsft_2-1669712777346.png

 

 

Select column ‘email address’ data.

vxiaochenmsft_3-1669712777347.png

 

 

Create an array and save only one email address for the same email address.

union(body(‘Select’),body(‘Select’))

vxiaochenmsft_4-1669712777348.png

 

 

Create an empty array.

vxiaochenmsft_5-1669712777348.png

 

 

Add 'Apply to each' to get the properties of the files in the library and filter the same data as the current email address.

Items(‘Apply to each’)?[‘Email’]

vxiaochenmsft_6-1669712777353.png

 

 

Based on the results of the ‘Filter array’, create another 'Apply to each'. Get the file contents based on the path.

items('Apply_to_each_2')['{FullPath}']

vxiaochenmsft_7-1669712777354.png

 

 

Append the following to the empty array.

{"Name": items('Apply_to_each_2')['{FilenameWithExtension}'],

"ContentBytes": body('Get_file_content_using_path')}

vxiaochenmsft_8-1669712777355.png

 

 

Send email with array 'varFile' attached. Finally, set the array to empty.

Items(‘Apply_to_each’)?[‘Email’]

vxiaochenmsft_9-1669712777358.png

 

 

Save flow and run it.

vxiaochenmsft_10-1669712777359.png

 

Best Regards,

Wearsky

Wow, thanks! It works perfectly. I just had a question about making it quicker. I tried to open up the concurrency settings in the 2 apply to each loops and it isn't working as well. 

 

Will this be able to process around 1k pdf files with emails, quickly? 

 

Thanks again for all the help, your solution helped me from going crazy!

 

 

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (1,724)