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 / UpdateContext to send ...
Power Apps
Answered

UpdateContext to send Emails

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I am trying to use the UpdateContext function to send emails. I am getting an error when I click submit button on my form. Anyone know if I am using the UpdateContext correctly. Thank you!

powerapps2.jpg

Here is my formula:

 

UpdateContext({e:If(DeptTxt.Text="Office","clericaltimeoff@xxxx.com", If(DeptTxt.Text="Operations","dispatchtimeoff@xxxx.com", If(DeptTxt.Text="Maintenance","mowens@xxxx.com", If(DeptTxt.Text="Management","managertimeoff@xxxx.com"))))});

Office365.SendEmail(e,"Time Off Request", "<b>Time Off Request for " & UserName.Text & "<br></b>" & "Department: " & DeptTxt.Text & "<br>" & "Date Submitted: " & TodaysDate & "<br><br>" & "Start Date: " & StartDate & "<br>" & "Start Time: " & StartTime.SelectedText.Value & "<br><br>" & "End Date: " & EndDate & "<br>" & "End Time:" & EndTime.SelectedText.Value & "<br><br>" & "Time Off Code: " & TimeOffRadio.SelectedText.Value & "<br>" & "Description: " & BriefDescription & "<br>" & "<br><br>" & "<b>REQUIRED FOR HOURLY EMPLOYEES</b>" & "<br>" & "Paid Compensation: " & Radio4.SelectedText.Value & "<br>" & "Makeup Time: " & Radio4_1.SelectedText.Value & "<br>" & "Makeup Hours: " & MakeupTime.Text & "<br>" & "Makeup Date: " & MakeupDate & "<br>" & "<br>" & "Go to the MANAGER screen to Approve/Reject the Time off Request" & "<br>" & "https://apps.powerapps.com/play/fa97404b-6670-4390-880a", {IsHtml: true});

Office365.SendEmail(User().Email, "Time Off Request Submitted", "Your Time Off Request has been submitted successfully.", {IsHtml: true});

SubmitForm(RequestForm);
ResetForm(RequestForm);
Navigate(LogoutScreen,ScreenTransition.Fade)
Categories:
  • mdevaney Profile Picture
    29,993 Moderator on at

    @Anonymous 
    This code is massive.  Are you able to isolate the error?  Trying removing sections of the code to figure out what works and what doesn't.

     

    Also, is it possible that none of your conditions in UPDATECONTEXT are being met resulting in a blank email?

     

     

    One suggestion I have is to make your UPDATECONTEXT more readable by using SWITCH instead of nested IF statements.

    UpdateContext({
     e: Switch(DeptTxt.Text
     "Office","clericaltimeoff@xxxx.com",
     "Operations","dispatchtimeoff@xxxx.com",
     "Maintenance","mowens@xxxx.com",
     "Management","managertimeoff@xxxx.com"
    })

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @mdevaney 

     

    I ran the app using the Monitor tool to see if that would help. I have attached the data. It shows on line 35 of the Monitor report  a Bad Request. Any ideas? Thank you.

     

     

  • mdevaney Profile Picture
    29,993 Moderator on at

    @Anonymous 

    The problem appears to be with the 'createRow' open so maybe it has to do with submitting the form.

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @mdevaney 

     

    I removed my data sources and then saved, and then re-added data sources to see if that would fix the problem. Now the only error i have is: Invocation of unknown or unsupported function on the SendEmail formula

     

    powerapps3.jpg

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @mdevaney 

     

    I did some reading and found out the connector I was using Office365.SendEmail, was incorrect. It should be Office365Outlook.SendEmail. So now I have no errors showing, however, it still is not successful when clicking Submit button. Still have the Bad Request. Also, the App Checker shows zero errors in formulas. Strange....

  • Verified answer
    mdevaney Profile Picture
    29,993 Moderator on at

    @Anonymous 
    I think you should be using the function Office365Outlook.SendEmailV2 instead of Office365Outlook.SendEmail.

     

    Can you please try that and let me know the result?  Also, do you have the Office365Outlook connector added to the app?

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @mdevaney 

     

    Does the Office365Outlook.SendEmailV2 connector work differently?

  • mdevaney Profile Picture
    29,993 Moderator on at

    @Anonymous 

    Yes.  Additionally, V1 is deprecated so it could be removed at any time.

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "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 382 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 329

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard