Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Outlook Connector - Navigate Home ONLY if email sent successfully

(0) ShareShare
ReportReport
Posted on by

Hello, I am using the Outlook Connector Send Email action to send an email. Within the onSubmit action, the email is sent, then the item is updated, and the user is navigated back home. The issue is that if the email fails to send, the item is still updated, and user is navigated back home. Is there some type of code/function I could add to only do the other two items if the email sent successfully? So wondering if there is a IsValid or send equals to true or something? 

 

Here's my formula that I am currently using. 

 

Office365Outlook.SendEmail(To_TI.Text,Subject_TI.Text,EmailBody_HTML.HtmlText,{Bcc:BCC_TI.Text,Cc:CC_TI.Text,From:From_TI.Text,Importance:"Normal",IsHtml:true,ReplyTo:"email@address.com"}); Patch(DATASOURCE,LookUp(DATASOURCE,ID =Gallery.Selected.ID),{Datasource Column:"Value"})
  • Melinda Profile Picture
    Melinda on at
    Re: Outlook Connector - Navigate Home ONLY if email sent successfully

    @WarrenBelz that worked perfectly! Only required change was updating the semicolon to a comma before the second if statement. I marked it below in the code you provided. 

     

    UpdateContext({varEmailErr: false});
    IfError(
     Office365Outlook.SendEmail(
     To_TI.Text,
     Subject_TI.Text,
     EmailBody_HTML.HtmlText,
     {
     Bcc: BCC_TI.Text,
     Cc: CC_TI.Text,
     From: From_TI.Text,
     Importance: "Normal",
     IsHtml: true,
     ReplyTo: "email@address.com"
     }
     ),
     UpdateContext({varEmailErr: true})
    );
    If(
     !varEmailErr,
     Patch(
     DATASOURCE,
     {
     ID: Gallery.Selected.ID,
     Datasource Column: "Value"
     }
     )
    )

     

  • Verified answer
    WarrenBelz Profile Picture
    WarrenBelz 145,666 on at
    Re: Outlook Connector - Navigate Home ONLY if email sent successfully

    Hi @Melinda ,

    Try this

    UpdateContext({varEmailErr: false});
    IfError(
     Office365Outlook.SendEmail(
     To_TI.Text,
     Subject_TI.Text,
     EmailBody_HTML.HtmlText,
     {
     Bcc: BCC_TI.Text,
     Cc: CC_TI.Text,
     From: From_TI.Text,
     Importance: "Normal",
     IsHtml: true,
     ReplyTo: "email@address.com"
     }
     ),
     UpdateContext({varEmailErr: true})
    );
    If(
     !varEmailErr,
     Patch(
     DATASOURCE,
     {
     ID: Gallery.Selected.ID,
     Datasource Column: "Value"
     }
     )
    )

     

    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

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,666

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,996

Leaderboard