cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
donewithcrayons
Frequent Visitor

Power Automate sending multiple email

Hi All, 

I have a sharepoint list which contains an email address and a link which is unique to that user and all it need to do is go through that list and email the user a link. (pics below of the list and the flow) nothing super complex there. The flow works as expected however it sends duplicates of the email. I'm really new to Power Automate and so any advice would be greatly appreciated.

 

list.PNG

flow.PNG

1 ACCEPTED SOLUTION

Accepted Solutions

Here is the logic above in screenshots.

1) Sort the Get Items by email address

image.png

2) Create a variable to hold the email address and an array to hold the links.  Another to hold the first name if you want to use that in the email

image.png

3) Loop through the items.  Add a condition to see if the current email is equal to either the first run or the previous email processed.

image.png

4) if it is the first loop or the email is equal to the last one processed the save the email and append the link.

image.png

5) If its a new email then create an HTML table from the links array and send the email.  Then save update the email with the new email and reset the array with the new link.

image.png

6) When you exit the loop process the last email 

image.png



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

5 REPLIES 5
fchopo
Super User
Super User

Hi @donewithcrayons 

I provided a similar answer to the same problem in this thread: Re: Create Approval for Multiple SharePoint List I... - Power Platform Community (microsoft.com)

The idea is to do a group by operation, grouping items by approver, and then sending a unique email. Have a look at this excellent blog post by @JohnLiu : Do Group By in Microsoft Flow with two simple elegant loops — John Liu .NET

Hope it helps!

Ferran

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!
Pstork1
Dual Super User III
Dual Super User III

The problem is that you are sending the emails inside the loop.  So each time you process a link it sends a new email.  To only send one email per user you need to gather up all the links for each user inside the loop and then send the emails after you exit the loop.  Here's the pattern you will need to follow.

1) Sort the Get Items by user email

2) Initialize a variable of type array called varLinks to hold the links

3) Initialize a variable of type string called varEmail to hold the current user email. Set it to "First"

4) Now start your loop on Get Items.  Inside the Loop do the following

    a) Check to see if varEmail is equal to the current user or "First"

    b) If it is then set varEmail to the email of the current item and append the link to varLinks array

    c) If it isn't then convert varLinks to an HTML table and send an email with the Table to varEmail.

        -After sending the email set varEmail to the current item email and set the varLinks array to the current Link

    d) After the Loop exits convert varLinks to an HTML table and send an email with the Table to varEmail one last time to get the last set of links



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

I really appreciate the quick replies, is there any way you can break it down further?

I think I understand what your telling me to do but at the same time I don't. I'm totally new to this and don't have a programming background. 

Here is the logic above in screenshots.

1) Sort the Get Items by email address

image.png

2) Create a variable to hold the email address and an array to hold the links.  Another to hold the first name if you want to use that in the email

image.png

3) Loop through the items.  Add a condition to see if the current email is equal to either the first run or the previous email processed.

image.png

4) if it is the first loop or the email is equal to the last one processed the save the email and append the link.

image.png

5) If its a new email then create an HTML table from the links array and send the email.  Then save update the email with the new email and reset the array with the new link.

image.png

6) When you exit the loop process the last email 

image.png



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

donewithcrayons
Frequent Visitor

That's amazing, thank you so much. Have to say I'm happy I asked I never would have gotten that on my own.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Users online (2,241)