cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Lefty
Post Prodigy
Post Prodigy

sending an email to multiple users

Hi everyone,

 

I have a requirement to email 5 users, normally I would just reference the datacard like below:

Office365Outlook.SendEmailV2(VarPatchedRecord.IssuedTo.Email, "An application has been submitted by  " & DataCardValue8.Selected.DisplayName, " Please review the application <br>  <a href='https://apps.powerapps.com/play/--------------&PD=" & VarPatchedRecord.ID & "'> You can review and action the request here </a> "
 & "<br><br> Kind regards, <br>

 

The problem is I don't have a field with the 5 users but I have on my App OnStart a table:

 

Set(MyApprovers, 
Table({MyUser: "Email1.uk"},
     {MyUser: "Email2.uk"},
     {MyUser: "Email3.uk"},
     {MyUser: "Email4.uk"},
     {MyUser: "Email5.uk"}
));

But can't refer to that in my code.... any best practice how I achieve this please?

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @Lefty ,

Do you want to send single one email to 5 users in your MyApprovers variable?

 

I have made a test on my side, please consider take a try to modify your formula as below:

Office365Outlook.SendEmailV2(
                             Concat(MyApprovers, MyUser & ";"),   // modify formula here
                             "An application has been submitted by  " & DataCardValue8.Selected.DisplayName, 
                             " Please review the application <br>  <a href='https://apps.powerapps.com/play/--------------&PD=" & VarPatchedRecord.ID & "'> You can review and action the request here </a> "
 & "<br><br> Kind regards, <br>"
)

 

In addition, I also agree with @Mr-Dang-MSFT 's thought almost. Please take a try with above formula, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

11 REPLIES 11
Mr-Dang-MSFT
Power Apps
Power Apps

Hi @Lefty ,

Suppose you have a table called MyApprovers with the 5 people you want to email. You can use the ForAll function to perform actions against each record in the MyApprovers table.

ForAll(
    MyApprovers,
    Office365Outlook.SendEmailV2(
        MyUser,
        "Lorem ipsum dolor sit amet."
    )
)

This means, "For each of the approvers, use the O365 Outlook connector to send an email to each respective user with the given message."

 

Let me know if you're able to use this. 

@Mr-Dang-MSFT suggested expression should work. Please also ensure that experimental feature, formula-level pre-fetching is disabled. There is an existing issue when you may see duplicate emails being send out when this feature is enabled.

v-xida-msft
Community Support
Community Support

Hi @Lefty ,

Do you want to send single one email to 5 users in your MyApprovers variable?

 

I have made a test on my side, please consider take a try to modify your formula as below:

Office365Outlook.SendEmailV2(
                             Concat(MyApprovers, MyUser & ";"),   // modify formula here
                             "An application has been submitted by  " & DataCardValue8.Selected.DisplayName, 
                             " Please review the application <br>  <a href='https://apps.powerapps.com/play/--------------&PD=" & VarPatchedRecord.ID & "'> You can review and action the request here </a> "
 & "<br><br> Kind regards, <br>"
)

 

In addition, I also agree with @Mr-Dang-MSFT 's thought almost. Please take a try with above formula, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

@Mr-Dang-MSFT @ShantanuP 

 

I've tried this and this is my code, but now i get no email triggered to anyone, not even cc'd

 

UpdateContext(
	{
	VarPatchedRecord:
	Patch(
		ListName, Defaults(ListName),
		Form1_2.Updates,
                Form1_6.Updates,
		Form1_7.Updates
        
    ) 
	}
);
If(Not(IsBlank(VarPatchedRecord.ID)),Navigate(SuccessScreen);

ForAll(MyApprovers,Office365Outlook.SendEmailV2(MyUser, "Application has been submitted by  " & DataCardValue8.Selected.DisplayName, " Please review the application <br>  <a href='https://apps.powerapps.com/play/0000000000000PID=" & VarPatchedRecord.ID & "'> You can review and action the request here </a> "

 

Hi @v-xida-msft 

 

Having tried your suggestions, i'm not able to patch my form, this is my entire code on my submit buttons OnSelect:

UpdateContext(
	{
	VarPatchedRecord:
	Patch(
		ListName, Defaults(ListName),
		Form1_2.Updates,
                Form1_6.Updates,
		Form1_7.Updates
        
    ) 
	}
);
If(Not(IsBlank(VarPatchedRecord.ID)),Navigate(SuccessScreen);

Office365Outlook.SendEmailV2(Concat(MyApprovers,MyUser & ";"),
"An application has been submitted by  " & DataCardValue8.Selected.DisplayName, " Please review the application <br>  <a href='https://apps.powerapps.com/play/0000&PD=" & VarPatchedRecord.ID & "'> You can review and action the request here </a> "
 & "<br><br> Kind regards, <br>

<br>Team name here
<br><b>Team name here</b> 
<br>Add here 
<br>
Email here"

,{Cc:DataCardValue8.Selected.Email & ";" & DataCardValue10.Selected.Email, Importance:"Normal"}))

 

@Lefty Please ensure that MyApprovers is not empty and has valid set of emails. Does it work when you just have that expression? You also have a If condition there, does Navigate get execute? You could also try putting ForAll before navigate. Both should work though.

v-xida-msft
Community Support
Community Support

Hi @Lefty ,

Is there something error message when you execute your whole formula?

Do you mean that the Patch formula could not be executed successfully in your app?

Have you tried to execute your Office365Outlook.SendEmailV2() formula individually in a button? Does it work?

 

According to the issue that you mentioned, I think this issue is related to your Patch formula itself rather than the Office365Outlook.SendEmailV2() formula. Please try to execute your Office365Outlook.SendEmailV2() formula individually in a button, then check if the email sent out properly as expected.

 

Please consider modify your formula as below:

Set(
    VarPatchedRecord,
    Patch(
          ListName,
          Defaults(ListName),
	  Form1_2.Updates,
          Form1_6.Updates,
	  Form1_7.Updates
        
    )
);
If(
   !IsBlank(VarPatchedRecord),
   Navigate(SuccessScreen);Office365Outlook.SendEmailV2(Concat(MyApprovers,MyUser & ";"),
"An application has been submitted by  " & DataCardValue8.Selected.DisplayName, " Please review the application <br>  <a href='https://apps.powerapps.com/play/0000&PD=" & VarPatchedRecord.ID & "'> You can review and action the request here </a> "
 & "<br><br> Kind regards, <br>

<br>Team name here
<br><b>Team name here</b> 
<br>Add here 
<br>
Email here"

,{Cc:DataCardValue8.Selected.Email & ";" & DataCardValue10.Selected.Email, Importance:"Normal"}))

If the issue still exists, please also consider remove the SP List connection from your canvas app, then re-create a new one to it from your canvas app, then try above formula again, check if the issue is solved.

 

Regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

HI @ShantanuP  @Mr-Dang-MSFT 

 

Thanks for this, it nearly worked, issue was as I am cc in 2 users as part of my code, those 2 users get cc'd every time the approver from my list is emailed so in my case 5 times, otherwise this is a brilliant way when i need to hide who is being emailed.

Is there anyway I can change the code to not have the users cc'd 5 times?

Hi @v-xida-msft 

 

Thank you, your response previously was in fact correct, I had some required (mandatory fields) which were causing the problem... I've successfully been able to implement the emailing to multiple users using your suggestion 

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

secondImage

Power Apps Community Call

Please join us on Wednesday, October 20th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

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.

Top Solution Authors
Top Kudoed Authors
Users online (3,387)