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

Collecting data from Text Input and sending e-mail

Hi.

 

I`m trying to have a checkbox where when it`s checked it gathers information from a Text_Input. The text_input is where a user will type his/her e-mail, and when the checkbox is checked, an confirmation e-mail is sent to the e-mail that the user has provided. 

 

Please see attached picture of the code I have tried. 

 

I`m fairly new to PowerApps, and not sure what I`m doing.. 

 

Thanks. 

 

1 ACCEPTED SOLUTION

Accepted Solutions

It might also be better to put the Submit function after you send the mail. Like this:

If(Checkbox1.Value, Office365.SendEmail(DataCardValue_emailAddress.Text, "Confirmation email", DataCardValue_emailBody.Text));
SubmitForm(EditForm1)

View solution in original post

9 REPLIES 9
QJappie22
Resolver II
Resolver II

Hi @OzmeR,

 

The code you used in the OnCheck property of the CheckBox can better be placed in the OnSelect property of the Submit button. Then if you select the Submit button AND the CheckBox is checked, it sends an email to the requestor. If the CheckBox is NOT checked, it doesn't send an email to the requestor after selecting the Submit Button.

I hope this will help you with your question!

OzmeR
Frequent Visitor

Hi. @QJappie22

 

Thanks for your answer, I tried to do that just now, but I get an error in formula.. 
Do you know what could be wrong with it, please see attached image. 

 

Thanks.

Hi @OzmeR 

The correct way to do this is to terminate the call to the SubmitForm function with a semi colon. You can then append your sendmail code beneath like so.

 

SubmitForm(EditForm1); 
If (Checkbox1.Value,
    Office365.SendEmail(... etc

 

OzmeR
Frequent Visitor

Hi @timl 

 

Thanks for your reply. 

I just tried that as well, but I still keep getting the error on formulas. It keeps telling me: Invalid number of arguments: received 2, expected 3-4. Button_Submit.OnSelect

 

I have tried as following: 

 

"SubmitForm(EditForm1);
If (Checkbox1.Value,
   Office365.SendEmail(Input_Email, "Confirmation email")"

 

and 

 

"SubmitForm(EditForm1);
If (Checkbox1.Value=true)
   Office365.SendEmail(Input_Email, "Confirmation email")"

 

and 

 

"SubmitForm(EditForm1);
If (Checkbox1.Value,true) 
   Office365.SendEmail(Input_Email, "Confirmation email")"

 

and 

 

"SubmitForm(EditForm1);
If (Checkbox1.Value;true) 
   Office365.SendEmail(Input_Email, "Confirmation email")"

 

and

 

"SubmitForm(EditForm1);
If (Checkbox1.Value=true) 
Office365.SendEmail(Input_Email, "Confirmation email"),COncatenate(Input_Email))"

 

and so on and so on.. 

 

I really cannot figure out why this is so difficult to do.. It`s so easy to define a e-mail address to send to, but not when you want the user of the app to type in the e-mail address they want to receive a copy to..

 

Thanks. 

OzmeR
Frequent Visitor

I have also tried with: " SubmitForm(EditForm1); If(Checkbox1.Value=true); If(Input_Email.Value, Office365.SendEmail(Input_Email.Text, "Subject" , "Confirmation e-mail"),false;SubmitForm(EditForm1) "

 

But this also gives me errors..

Hi @OzmeR,

 

The Office365.SendEmail function expects 3 parameters. So you formula should be:

SubmitForm(EditForm1);
If(Checkbox1.Value, Office365.SendEmail(DataCardValue_emailAddress.Text, "Confirmation email", DataCardValue_emailBody.Text))

DataCardValue_emailAddress must be replaced by the name of your DataCard name for the requestor. Same goes for DataCardValue_emailBody: replace this with your DataCard name for the Body of the email.

Don't forget to put .Text after the DataCard names.

 

Does this do the trick for you?

It might also be better to put the Submit function after you send the mail. Like this:

If(Checkbox1.Value, Office365.SendEmail(DataCardValue_emailAddress.Text, "Confirmation email", DataCardValue_emailBody.Text));
SubmitForm(EditForm1)

View solution in original post

Hi @OzmeR 

Can you try this and see if you get the same error?

SubmitForm(EditForm1); 
If (Checkbox1.Value,
    Office365.SendEmail(Input_Email.Text, "Email Subject", "Email Body")
)
OzmeR
Frequent Visitor

Hi @QJappie22 

 

Holy moly! It worked!! I have been pulling my hair out for days trying to get this sorted! 

Thank you so much for your help!

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
Top Kudoed Authors
Users online (1,342)