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 / How to use Set(variabl...
Power Apps
Answered

How to use Set(variable with ForAll ?

(0) ShareShare
ReportReport
Posted on by 997

Hello,

How to use a variable if you used a ForAll ?

Because the error says we can use it because we have ForAll

ForAll(
 EmailCollection;
 IfError(
Set(yesbeensent;false);;
// Iterate through each group and send emails
SMTP.SendEmailV3({To: "demo@demo.com"; Subject:"test";
 Body: "<!--Header-->
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'> 
<html xmlns:v='urn:schemas-microsoft-com:vml'>
<head>
	<meta http-equiv='content-type' content='text/html;charset=UTF-8'>
</head>

<body bgcolor='#eeeded'>
</html>"
 ;IsHTML: true}
 );Notify("E-mail" & " did not send.");Set(yesbeensent;true)

 )
)

I like to use the yesbeensent as a check-up to run some code after it

Thanks

Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    156,074 Most Valuable Professional on at

    @TimmyBoy ,

    Quite simply, you cannot set a Variable inside a ForAll statement. It is also a waste of time putting a Notify in there as well. You can however do this

    Clear(colErrors);;
    ForAll(
     EmailCollection;
     IfError(
     SMTP.SendEmailV3(
     {
     To: "demo@demo.com"; 
     Subject:"test";
     Body: "<!--Header-->
     <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'> 
     <html xmlns:v='urn:schemas-microsoft-com:vml'>
     <head>
     <meta http-equiv='content-type' content='text/html;charset=UTF-8'>
     </head>
     <body bgcolor='#eeeded'>
     </html>"
     ;IsHTML: true
     }
     )
     );
     Collect(
     colErrors;
     {Value: true}
     )
    );;
    If(
     CountRows(colErrors) > 0;
     Notify(
     CountRows(colErrors) & " E-mails" & " did not send.");
     NotificationType.Error
     )
    )

     

    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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • TimmyBoy Profile Picture
    997 on at

    Hi @WarrenBelz 

    Thank you, you are so amazing 😉
    Didn't know you could do that, learned again something new.

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

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 339 Most Valuable Professional

#2
11manish Profile Picture

11manish 180

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 88 Super User 2026 Season 1

Last 30 days Overall leaderboard