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 / Sending Emails using O...
Power Apps
Answered

Sending Emails using Office365.SendEmail()

(2) ShareShare
ReportReport
Posted on by Microsoft Employee

I want to send the email when a SharePoint list item is added and have several questions on how to process.

  1. I found that I can connect to Office 365 Outlook and use Office365.SendEmail() function which is pretty simple. The only question here is what is better in terms of which practice seems to be accepted or works the best. Compared to Sending Emails with using Microsoft Flow on PowerApp event, Microsoft Flow on SharePoint list event or sending within PowerApp using Office365.SendEmail(). Is there benefits of using one option over another?
  2. I have trouble getting email from a field. The field is People/Group in SharePoint. I have this function in the OnSuccess trigger of the form:
    Office365.SendEmail(DataCardValue17.Selected.Email,"TEST","TEST");Navigate(MainPage,ScreenTransition.Fade); ResetForm(FormCreateTravelRequest)

    When I run the app and the form I get the following error on the Office365.SendEmail() function:
    The service returned an error: Office365!SendEmail: The method ‘SendEmail’ has an invalid value for parameter ‘To’
    Here is the pic:
    issue1.png
    Now I thought maybe it is not pulling the email correctly from the form field, to test that out I created the Label1 and its text changed to:
    DataCardValue17.Selected.Email

    It appears to show the correct email. To test if it would work I changed the OnSuccess function to:
    Office365.SendEmail(Label1.Text,"TEST","TEST");Navigate(MainPage,ScreenTransition.Fade); ResetForm(FormCreateTravelRequest)

    I tried to run it again and now I get this error:

     

     

    The service returned an error: Office365!SendEmail: {“status”:404,”Message”:”User account does not exist”,”source”:”127.0.0.1”}
    Here is a pic:

     

    issue2.png

    I thought maybe its because it has mail.onmicrosoft.com suffix, even though I tried to send myself an email with the mail.onmicrosoft.com and it worked same as just using my real email address. To remove that I changed the text function of the label to:

    Substitute(DataCardValue17.Selected.Email,"mail.onmicrosoft.com","ca")

     

    However, this still produces same error (User account does not exist)

    So now I am at a loss, what I am doing not right when trying to send the email?

  3. I want to send a complex HTML email. How would I have to change the Office365.SendEmail() to do that?

    Is writing this function enough?

     

    Office365.SendEmail(Label1.Text,"<b>HTML TEXT</b><br><em>Hello World</em>","TEST",”isHtml:true”);

     

    Does it matter that I put all HTML in the Office.SendEmail() function, would it be better if I added an HTML text control and made it hidden and then just linked it to the function?

Any help really appreciated!

Categories:
  • v-micsh-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous,

     

    This sounds like the Office 365 Outlook service error. Please take a try to switch to a testing account (different email format, take a try with the free trial) and check to see if that would work.

     

    I just tested the following code:

    Office365.SendEmail(DataCardValue12.Selected.Email,"Text","Test")

    It works from my side, I received the corresponding Email.

    the format of the testing Email account is the following:

    name@Company.onmicrosoft.com

     

    Besides, to send the Email in HTML format, please try the following format:

    Office365.SendEmail(
     DataCardValue12.Selected.Email, // To field
     "Text", // Subject Field
     "<b><font color=blue>HTML</font></b>text" // Body Field, this could also be HtmlText1.HtmlText 
     {IsHtml:true} // the record elements for other parameter 
     )

    2.PNG

    Function reference:

    4.PNG

    Office 365 Outlook

    Regards,

    Michael

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @v-micsh-msft Thanks for the reply really appreciate that! Do you know what could be the problem with the Office 365 Outlook service or how to fix that? Also, are there other options to send email? 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I went ahead to do some testing and tried to create the email sending with the Flow.

     

    I set up my Flow to activate when the new item is added to SharePoint site. Whenever I try to run the flow I still get the same User account does not exist. I asked around my colleagues about our email system. We are using Sherweb service, would that be the issue as we are not using Exchange? If so, are there any work arounds?

     

    Also I tried to set up email with using simple Mail datasource from PowerApps. I tested it our by writing

    Mail.SendEmail(Label1.Text,"TEST",HtmlText3.HtmlText,{ishtml:true})

    However I get the following error:

     

     

    The service returned an error: Mail!SendEmail: The method 'SendEmail' has an invalid value for parameter 'to'

    But the email in Label1.Text is correct.

    When I did this:

     

     

    Mail.SendEmail("myemail@company.com","TEST","TEST")

    I did recieve the email. But that does not allow me to dynamically change the email or the body of the email.

     

  • Adi2ro Profile Picture
    42 on at

    It happened to me as well. It's an issues with the Studio Only. When you are in edit mode, if you navigate to that screen without actually selecting the dropdown, it doesn't "see" the value, even though the same value in a label works. So you can either make a label take the value and then import the value from the label in the Office365.SendEmail syntanx OR just try the app and it will work.

     

    I have noticed that there are some diferences between using the Studio and the Live app. In studio sometimes the values are not imported properly while using the app live, works as it should.

     

    See if using the app by Opening it, will still cause the error , if yes, try the solution with the label and using Label.Text to import that value into the email.

     

    I still strugle with another part: If I have two labels and one is blank, how can I use the TO field without using If's ... since if one is blank, the entire syntax fails as it cannot process blank values when sending the data to Office 365 Exchange for the TO Field. 

     

    Good luck!

  • Jasonkatz424 Profile Picture
    71 on at

    I found that using a flow button works.

  • Sru Profile Picture
    on at

    Hi @v-micsh-msft

     

    will it work if i use a sharepoint people picker with multiple selections? or if it has a sharepoint group name choosen

     

    Thanks,
    Sru

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Did anyone get any resolve to this issue without using MS Flow?

    I am the creator of an app and the Office365.SendEmail seems to work for me, but when I expand testing to other individuals in my organization they receive the error:

             "Office365.SendEmail failed: The method 'SendEmail' has an invalid value for parameter 'To' "

     

    I've verified all connections are made in the powerapps, and access has been granted to the SP list.

     

    Any thoughts @v-micsh-msft

     

    sendemail error.JPG

  • JMAFO Profile Picture
    303 on at

    Did you ever find the solution to this?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I used MS Flow to handle all emails. In general, MS Flows greatest asset is to perform an action based off a trigger. That trigger being selecting a button in a powerapp, then let Flow handle the action. I find that using that structure cleared the errors.

  • JMAFO Profile Picture
    303 on at

    I'll explore the option with Flow. I'm also integrating this powerapp onto a sharepoint page so that might be better anyway. Thanks tomgardzinski.

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 226 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 191 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 167

Last 30 days Overall leaderboard