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

Multiple emails from flow designed to send new list item details via email

Hi everyone,

I am very new to flow creation.  I have built a flow to send an email when a new item is entered into a list.  The body of the email contains the data entered in the new list item.  Attachments from the new list item are also sent as an attachment in the email.  At this point, the email output contains everything that it should.  The issue is that flow is sending the email 4 times.

 

I am sure this is due to the "apply to each" portion of the flow.  I have tried to move the send email part outside of the "apply to each" portion, but it does not work.

 

The first "for each" control was created to get the new list item attachment content.

 

The 2nd-4th "for each" controls were created automatically by Flow when I added the respective field from the list item to the output email body.  Each of the fields allow for more than one selection when creating the item.  These fields are "Category", "Items", and "Who needs to be involved?"

 

How do I correct this flow so that output email stays the same, but send sonly once?

 

bwright_0-1622814009607.png

bwright_1-1622815077819.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
ccc333ab
Solution Sage
Solution Sage

Yes, the 4 emails are due to the loops. You will want to send the email outside these loops, but to get your "multiple" attachments and "multiple" values from your list, you'll need to build up some "containers" to hold them in and attach them once into the email. 

 

Of note, you won't be able to send multiple attachments in the "Send Email Notification (v3)" action. I would recommend using the Outlook function Send an email (v2). I'll show you below one way to do all this: 

 

For attachments:

  1. Initialize a variable of type Array
  2. Loop through all attachments, and add it into the array variable. 
  3. In the Send an Email (v2), switch to use input array, and include your dynamic content from your array variable. 

ccc333ab_1-1622821245790.png

 

 

ccc333ab_0-1622821225159.png

(Hit the yellow highlighted button to use input array)

ccc333ab_2-1622821353032.png

ccc333ab_3-1622821389785.png

 

 

 

For Multiple values

  1. Initialize a string variable for all of your 3 fields that are of multiple values (category,  items, etc.)
  2. Loop through each one and append to your string variables
  3. Use this variable in your email 

(See this post: https://powerusers.microsoft.com/t5/General-Power-Automate/New-to-Power-Automate-Copying-items-from-...). 

 

This appends a comma after each loop, so you may want to put in logic to remove the last one if you want, or don't add it on the first loop, while adding the comma at the beginning of all other loops. 

 

View solution in original post

6 REPLIES 6
ccc333ab
Solution Sage
Solution Sage

Yes, the 4 emails are due to the loops. You will want to send the email outside these loops, but to get your "multiple" attachments and "multiple" values from your list, you'll need to build up some "containers" to hold them in and attach them once into the email. 

 

Of note, you won't be able to send multiple attachments in the "Send Email Notification (v3)" action. I would recommend using the Outlook function Send an email (v2). I'll show you below one way to do all this: 

 

For attachments:

  1. Initialize a variable of type Array
  2. Loop through all attachments, and add it into the array variable. 
  3. In the Send an Email (v2), switch to use input array, and include your dynamic content from your array variable. 

ccc333ab_1-1622821245790.png

 

 

ccc333ab_0-1622821225159.png

(Hit the yellow highlighted button to use input array)

ccc333ab_2-1622821353032.png

ccc333ab_3-1622821389785.png

 

 

 

For Multiple values

  1. Initialize a string variable for all of your 3 fields that are of multiple values (category,  items, etc.)
  2. Loop through each one and append to your string variables
  3. Use this variable in your email 

(See this post: https://powerusers.microsoft.com/t5/General-Power-Automate/New-to-Power-Automate-Copying-items-from-...). 

 

This appends a comma after each loop, so you may want to put in logic to remove the last one if you want, or don't add it on the first loop, while adding the comma at the beginning of all other loops. 

 

View solution in original post

bwright
Frequent Visitor

Thanks so much for your reply!  This is working great for the multiple values issue, however I am unable to get the attachment to send with the email...attachment structure is setup per your advice using Send an Email v2.

 

Any thoughts on the attachment missing?

ccc333ab
Solution Sage
Solution Sage

Are you able to grab a screen shot of: 

  • Your append to array variable action
  • Your Send an Email v2 action
bwright
Frequent Visitor

I figured it out...I typed "Content" in the array variable action instead of "contentbytes"

 

Thanks for your help with this!

HarshavardhanG
Helper I
Helper I

Hi @bwright , 

 

Can you please post the steps post suggestions by ccc333ab ?

The screenshots of your final flow will help users (like me) who visit this thread in the future.

Hi @HarshavardhanG,

Absolutely.  Below is the finished flow.

 

SQPEmailFlow1.PNG

 

SQPEmailFlow2.PNG

 

SQPEmailFlow3.PNG

 

SQPEmailFlow4.PNG

 

SQPEmailFlow5.PNG

 

SQPEmailFlow6.PNG

 

SQPEmailFlow7.PNG

 

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Solution Authors
Users online (1,714)