web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Send email to multiple...
Power Apps
Answered

Send email to multiple email addresses in a collection

(0) ShareShare
ReportReport
Posted on by 183

I have a collection called colReviewResults. Inside that collection, I have a column called matchFound that holds single (or multiple) email addresses per row ~each email address separated by a " ; "

 

1.6.21 single screenshot.PNG

 

---

 

jharville1_0-1609952113870.png

 

 

The code (in the OnSuccess of my EditForm) I used to send emails is:

 

 

With(
 {
 wEmails: Concat(
 colReviewResults,
 matchFound & ";"
 )
 },
 Office365Outlook.SendEmail(
 Left(
 wEmails,
 Len(wEmails) - 1
 )

 

 

 

 

 The above code works to send out single email addresses, but does not send out multiple email addresses (that are typed into my SharePoint list as single line of text with each email address separated by a semi-colon). Also, after it successfully sends an email (if it's only a single email address in the collection) and I open a new form, fill it out, and submit it to send another email (to a single email address in the collection), no email is sent. Would anybody know the reason why these 2 capabilities aren't functional? Thank you.

Categories:
  • Verified answer
    WarrenBelz Profile Picture
    156,566 Most Valuable Professional on at

    Hi @jharville1 ,

    Firstly, you have matchFound in your code and your field is matchfound, but other than that, what result do you get if you run the code to get colReviewResults and then put this on a Label Text on the form?

    Concat(colReviewResults, matchfound & ";")

    Your code should work and  produce all the email addresses from what you have posted.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

     

  • jharville1 Profile Picture
    183 on at

    I tested the functionality of my app again, and when the user creates a new form, fills it out, and submits it, it functions correctly and sends an email to the single or multiple email addresses (depending on which review item is selected).

     

    However after submitting the initial form, when I go back and try to create another new form and submit again, no email notification is sent to neither a single nor multiple email addresses. Would you know of any reason why this is happening? Possibly something with my location of code in the app form's OnSuccess or some other code in my app's initial OnStart?

  • WarrenBelz Profile Picture
    156,566 Most Valuable Professional on at

    @jharville1 ,

    That is why I asked you to test the collection result - when and where do you collect colReviewResults?

  • jharville1 Profile Picture
    183 on at

    I appreciate the response Warren. It is in the OnSuccess of my Form:

     

    jharville1_0-1610072692272.png

     

    The colReviewResults is only found in the screenshot I attached above and the function to send the emails.

     

    Also, I forgot to mention I adjusted the the matchfound to be matchFound before posting this post on the forum. My apologies.

  • WarrenBelz Profile Picture
    156,566 Most Valuable Professional on at

    You are clearing it on the OnSuccess (which is why you are getting no email addresses).

    You need to get rid of that code line, but also, where do you Collect it?

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

     

    Thanks @jharville1 ,

  • jharville1 Profile Picture
    183 on at

    @WarrenBelz 

     

    I removed the Clear() function and it gets rid of the problem of not allowing any additional forms to send email notifications once submitted. But now, the collection contents don't update with each additional new form after the first form is submitted. The email addresses in my collection just stay the same, when I need them to change with each additional form.

     

    Also, I believe this is where the colReviewResults is collected (within the ForAll() statement):

     

    jharville1_0-1610131297879.png

     

    I tried changing the Collect() to a ClearCollect() but it say's that a ClearCollect() cannot be invoked within a ForAll() function.

     

     

     

  • WarrenBelz Profile Picture
    156,566 Most Valuable Professional on at

    @jharville1 ,

    Sorry missed that - forget the clear.

    I will now go back to the debugging exercise - you need to find out when and where you have your email data in colReviewResults.

    So can you please save a form and put a label on the screen with

    Concat(colReviewResults, matchfound & ";")

    If you have no data, then the Collect has not worked.

    For the code, OnSuccess of the form should do the job as long as valid. I notice nested ForAll statements - you are actioning colCombinedCountryRevMaterial and all entries will come from this. What is the purpose of the outer loop on colReviewUsers?

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

     

  • WarrenBelz Profile Picture
    156,566 Most Valuable Professional on at

    Hi @jharville1 ,

    Just checking if you got the result you were looking for on this thread. Happy to help further if not.

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • jharville1 Profile Picture
    183 on at

    @WarrenBelz 

     

    Hi Warren!

     

    Sorry for the late response, I was working on your debugging method and had some issues. I used the label with the coding you provided, and oddly enough there were no results, which must mean nothing was collected. However, emails are still sent when the form is submitted. 

     

    I thought the data was collected for colReviewResults within the Collect() statement within the nested ForAll() function to send the emails once the form is submitted, but your label testing method says otherwise. 

     

    The current issue with the send-email function is that it won't update after the first form is submitted and a new form is filled out/submitted. The collection contents (email addresses) stay the same and won't update to the supposed, new collection contents from the new form.

     

    I tried adding a Clear(colReviewResults) to the end of my code of the OnSuccess of my Edit Form but it doesn't work ~ it actually makes the collection not collect any contents at all. I did the same of placing Clear(colReviewResult) to the OnVisible of my Edit Screen and the OnStart of my app but both had the same outcome.

     

    I even tried using If() Statements to say that: If() = varRecord.FormStatus = "New", Clear(colReviewResults) ... but that didn't work either.

     

    Essentially, all I need is for:

         When the form is submitted, emails should be sent to the email addresses listed in the colReviewResults collection ~ this part is successful

         Once the emails are sent out, the collection should be cleared so that the next new form's selections can determine what items (email addresses) should go in the collection ~ this part is not successful - the collection stays the same and does not update when a new form is being filled out after the original form

     

    And for further detail...

    *the first ForAll(colReviewUsers) takes into account the collection that is created from the OnStart of the application ~ it pulls all information from our list ('cfa review materials') ... which holds all info for "Country" and "Review Material"

    *the second ForAll(colCombineReviewMaterial) is a collection that concatenates the Country name selected from our form's combo-box with each of the Review Materials selected from the form's combo-box (ex: "France * January" ) ... and puts it under the column "Value" .

     

    ...If the "Value" column matches the "FullFieldName" column value from the colReviewUsers, it will collect the value the 3 values stated in my code (based on what the user selects in the form) into another collection, colReviewResults.

     

    I know that this is a bit of a tricky situation so I sincerely appreciate your time, help, and efforts.

  • WarrenBelz Profile Picture
    156,566 Most Valuable Professional on at

    @jharville1 ,

    To summarise this (so I can get my head around it) - you are saying the code works for the first form, but not for subsequent forms?

    The label testing confirms it is being cleared immediately after the OnSuccess is run (you may need to find where this is as it is after the OnSuccess code somewhere. Even stranger is what you are saying about the new form having the old addresses as the label confirms they are no longer there. You can also do View > Collections > colReviewResults and confirm it is empty. If it is empty, how are the old addresses reappearing?

    I also am finding the nested ForAll statements a little intriguing - you are not referring to anything in the outer item (or are you), so why is it there?

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 381 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 340

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard