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 / Help! Office365Outlook...
Power Apps
Answered

Help! Office365Outlook.SendEmail Fail using If Statements

(0) ShareShare
ReportReport
Posted on by 88

Hi 

 

I new to Powerapps and have created a simple application which enables user to write data to a SharePoint List. I am also using the Office365Outlook.SendEmail function to send a fancy html email upon submission of the form. 

 

I am using if statements to send emails depending on what data is inputted or selected on the entry form. Here is my formula: 

 

Office365Outlook.SendEmail(
"jon@hotmail.co.uk" & If(
DataCard1.Selected.Value = "Chicken Soup",
"jane@hotmail.co.uk"
),
"Subject: " & DataCard2,
'HTMLEmail'.HtmlText,
{
IsHtml: true,
Importance: "High"
}
) & SubmitForm(Form1);
NewForm(Form1);
Navigate(
'Thank You Screen',
ScreenTransition.Fade
)

 

So when a user submits a form, all emails are sent to jon@hotmail.co.uk. But if Chicken is selected in the DataCard1 Combo box, then this includes jane@hotmail.co.uk into the email also. 

 

This worked for a bit, but now when DataCard1 meets the criteria of "Chicken" it seems to break and I get the attached error message and no email is sent to anyone.

 

Not sure if its me or something else, but I need someones help to resolve this. 

 

Thanks,

 

 

Capture.JPG
Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    154,399 Most Valuable Professional on at

    Hi @Enriquitio ,

    Try this and note the comments on the datacard -  xxxx means Value/Distinct/FieldName depending on Items if Dropdown/Combo

    Office365Outlook.SendEmail(
     If(
     DataCard1.Selected.Value = "Chicken Soup", 
     "jon@hotmail.co.uk"; "jane@hotmail.co.uk",
     "jon@hotmail.co.uk"
     ),
     DataCard2.Text, //Note if dropdown will be DataCard2.Selected.xxxx
     'HTMLEmail'.HtmlText,
     {
     IsHtml: true,
     Importance: "High"
     }
    );
    SubmitForm(Form1);
    NewForm(Form1);
    Navigate(
     'Thank You Screen',
     ScreenTransition.Fade
    )

     

    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.

  • Enriquitio Profile Picture
    88 on at

    Hi @WarrenBelz

     

    Thanks for the speedy response. I think this works, however, it sends an email separately to each email and I would like it to add the 'If' email addresses to the static emails. 

     

    Also I want to avoid duplicated the static email (jon@hotmail.co.uk) like you have in your example. I would like to expand this to more values also from the combo box but not sure how. 

     

    Thanks,

     

     

  • WarrenBelz Profile Picture
    154,399 Most Valuable Professional on at

    Hi @Enriquitio ,

    I am not quite clear on your requirements - are you wanting to select multiple recipients from a Combo Box and send to them all?

    Using ComboBox1 as the name of your control

    Office365Outlook.SendEmail(
     Concat(ComboBox1.SelectedItems, Value & "; "),
     DataCard2.Text, //Assume subject is a text box
     'HTMLEmail'.HtmlText,
     {
     IsHtml: true,
     Importance: "High"
     }
    );
    SubmitForm(Form1);
    NewForm(Form1);
    Navigate(
     'Thank You Screen',
     ScreenTransition.Fade
    )

     

    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.

  • Enriquitio Profile Picture
    88 on at

    @WarrenBelz  Apologies, let me try and explain this better. 

     

    So when a user submits a new report form on the app I want to send an email notification to multiple colleagues. When I say static, I mean regardless of what is being entered onto the edit form, these people will get an email. 

     

    Now when a user selects certain value, say "chicken" from the one of the combo boxes, I want to use an If statement to add that person or persons into the email chain along with the static emails addresses already getting the email? Does that help? 

     

     

  • WarrenBelz Profile Picture
    154,399 Most Valuable Professional on at

    Thanks @Enriquitio ,

    When you say one of the combo boxes, how may are there and what is the Items property of these - a screenshot would be good.

    This is also getting quite a bit different from your post which asked for valid code to send an email (which has been solved).

  • Enriquitio Profile Picture
    88 on at

    @WarrenBelz I really do appreciate your support with this. Your solution helped and worked, but wasn't right to progress the project and yes this is evolving and again I appreciate your support.  

     

    So there is just the one combo box that I wa target a certain value, the item property is IncidentType. Please see the example of the dropdown options attached. So for example, if I was to choose "Disease" then I would like to add a certain work colleague into the email chain, otherwise they don't need to be sent an email. That help? 

     

     

     

     

    Capture.png
  • Verified answer
    Enriquitio Profile Picture
    88 on at

    @WarrenBelz I have figured it out. All this needed was a semicolon adding to the first email address.... Thank you so much for your time and support though!

     

    Office365Outlook.SendEmail(
    "jon@hotmail.co.uk;" & If(
    DataCard1.Selected.Value = "Chicken Soup",
    "jane@hotmail.co.uk"
    ),
    "Subject: " & DataCard2,
    'HTMLEmail'.HtmlText,
    {
    IsHtml: true,
    Importance: "High"
    }
    ) & SubmitForm(Form1);
    NewForm(Form1);
    Navigate(
    'Thank You Screen',
    ScreenTransition.Fade
    )

  • WarrenBelz Profile Picture
    154,399 Most Valuable Professional on at

    Happy to help @Enriquitio ,

    You have accepted your own response as a solution rather than the original item of mine solving this.

    Please consider correcting this to help others find the answer.

  • Enriquitio Profile Picture
    88 on at

    Hi @WarrenBelz 

     

    Yes absolutely! 

     

    Thanks,

    Harry

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
Haque Profile Picture

Haque 85

#2
WarrenBelz Profile Picture

WarrenBelz 76 Most Valuable Professional

#3
Kalathiya Profile Picture

Kalathiya 38 Super User 2026 Season 1

Last 30 days Overall leaderboard