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

Sending multiple emails with multiple attachments from different onedrive folders

 

I need to automatically send out monthly report emails with multiple attachments to each of our clients. 

 

So my flow references an excel table with two columns, client name and client email address. Based on the client name, It then searches the monthly reports onedrive folder for the matching folder name (which is the client name) , gathers all files in that folder, and puts them in an array. Then it sends out an email with the monthly reports to each client email address listed in the second column of the excel table.

 

Everything is working fine except it attaches every file from every folder and sends them to every client. I only need each client to receive their client-specific files stored in the onedrive folders labeled as their name. 

 

Is their some way to make the array reset and loop to get new attachments? Or do I need to have a different array for each client? I have researched this endlessly and since my case is very specific have had trouble finding answers. Any help is appreciated. 

 

 

 

1.PNG2.PNG

 

I had to put in this condition because the flow kept failing with a 404 error because the find files in folder step above listed the folders as a file, so the get file content step below didn't recognize it as a file

 

3.PNG4.PNG

2 REPLIES 2
Ventit
Resolver I
Resolver I

You need to reset the array after each run as it will just keep adding the files.  The way I do it is to initialise a second array variable.  After I build the array I send the email to the client,  then I reset the array to equal the second array which is blank.  the for each runs again and redoes the process.  This means you need to find a way in the process to run your email each time the list of attachments is completed.  Given your first Apply to each,  it needs to be inside that as I assume it now has one client that is matching, so steps would be

 

  1. List Rows in Excel
  2. Apply to each for each row
    1. Do your file search which would be another  apply to each
    2. After that apply to each and outside it,  but inside the first apply to each, attach and send email.  The TO Should only be based on the client now so only one email
    3. Reset your array with the blank array
  3. The process should now loop through and send one email to each client with their attachments.  The way I test this is to put my email in the TO so I get a copy of them all and put the email of the client in the body.   If I get the emails ok and the client name is OK.  I fix the email to go to the client for next time

 

 

ChristianAbata
Community Champion
Community Champion

hi @Ventit Apply to each means you will  loop one by one all values inside your Sharepoint List. If you want to avoid that don't use excel values from excel.



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

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

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Top Kudoed Authors
Users online (4,684)