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

Send Email Based on Text Input

I need some assistance with sending emails from my PowerApp. I have a Collection setup with several different Departments and their corresponding email address. Then I have a form that has a Text Input for the Department. On success of the Form, I want to send an email to the correct email address depending on the Department.

 

So for example:

If Department Text Input is Maintenance, the email should send to maintenance@xxxx.com,

If Department Text Input is Operations, the email should send to ops@xxxx.com,

If Department Text Input is Office, the email should send to clerical@xxxx.com.

 

I have tried similar IF statements in my formula but nothing is wokring. Any help or guidance would be appreciated. Thank you.

27 REPLIES 27

@thunter 

Go into the View menu and look at your collection...does it have any values in it?

My guess is that it is empty.

 

If you have this in your OnStart and you have made any alterations to it - Please make sure that you click on the three dots next to "App" in your Tree View and choose "Run OnStart".

Anytime you make changes in there, you need to rerun the OnStart to make it work in the designer.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@RandyHayes 

 

All the Departments and the correct emails are populated in the Collection. Still nothing showing in the "test" Label.

@thunter 

Just noticed in your picture... You are trying to Lookup "MANAGEMENT.  You do not have a "MANAGEMENT" in your collection.

You do have a "Management" but that is not the same.  Comparisons are EXACT, including Case.

You have a couple options:

1) Change your collection to have all lowercase Dept names and then change your formula to this:

    Lookup(Emails, Dept=Lower(DepartmentTxt.Text, EmailAddr)

 

2) Use the new Proper function:

    Lookup(Emails, Dept=Proper(DepartmentTxt.Text, EmailAddr)

    This will upper the first character and lower the rest.

 

Either will work in this scenario.  But, the point is, you have to match exact to get the results you want.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@RandyHayes 

 

So I have changed the Dept column to be in ALL CAPS now to match the Department Text field. I refreshed the App and ran OnStart, still nothing in "test" Label.

If you save entered department to the data source try to use column names:

form.OnSuccess = 
Office365Outlook.SendEmailV2(LookUp(Emails, Dept=YourForm.LastSubmit.DepartmentColumn).EmailAddr,

"Time Off Request",
"<b>Time Off Request for " & YourForm.LastSubmit.NameColumn & "<br></b>
Department: " & YourForm.LastSubmit.DepartmentColumn & "<br>
Date Submitted: " & Today() & "<br><br>
Start Date: " & YourForm.LastSubmit.SdateColumn & "<br>
Start Time: " & YourForm.LastSubmit.StimeColumn & "<br><br>
End Date: " & YourForm.LastSubmit.EdateColumn & "<br>
End Time:" & YourForm.LastSubmit.EtimeColumn & "<br><br>
Time Off Code: " & YourForm.LastSubmit.TOCColumn & "<br>
Description: " & YourForm.LastSubmit.BriefDescColumn & "<br><br><br>
<b>REQUIRED FOR HOURLY EMPLOYEES</b><br>
Makeup Hours: " & YourForm.LastSubmit.MUTimeAmtColumn & "<br>
Makeup Date: " & YourForm.LastSubmit.MUDateColumn & "<br><br>
Go to the MANAGER screen to Approve/Reject the Time off Request" & "<br> https://apps.powerapps.com/play/fa97404b-6670-4390-880a-30382b3dfb65?tenantId=213d2abe-37c2-40af-8c3...

);

 

 

if you do not save department:
submissionButton.OnSelect = 
Set(varEnteredDpt, Trim(DepartmentTxt.Text));
SubmitForm(YourForm);

YourForm.OnSuccess = 
Office365Outlook.SendEmailV2(LookUp(Emails, Dept=varEnteredDpt), "Time Off Request", .... etc (same code as above);
Set(varEnteredDpt, "");

 

Just an FYI for all following.

@thunter and I spoke offline about the issue he was having, mostly because it was related to the same problem he was having last week that I helped him through.

Turns out the issue was padding on the field he was working with.  Very common with certain SQL column, it had spaces padding the value we were trying to compare.

Using a Trim did the trick!

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
MickNaul
New Member

Hello, 

 

I'm Trying to do something in power apps, it's close to the subject already treated " Send Email Based on Text Input with contains", but little bit diiferent. ANd unfortunately I didn't find any advice or solution to solve my issue.

 

I would linke send a mail depending on text Input :

 

If text box contains "FLU-xxxxx" send mail to "JL@xxxxx.com"

If text box contains "MTG-xxxx" send mail to "GB@xxxx.com"

and ect.

 

I try to find the function contains, but nothing on it.

 

Could you please help me.

 

Thanks for feedback.

 

Mick 

Please post this as a new question.  You'll get more notice that way and others will be able to find the answer easier later.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (1,385)