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 / SendEmailV2 Runtime Error
Power Apps
Unanswered

SendEmailV2 Runtime Error

(0) ShareShare
ReportReport
Posted on by

I have an app which updates a Sharepoint List from a user's input on a form. Users submit their updates using a button which patches. I want that, based off a toggle, right after the patch occurs the necessary owners of the updated row of data are automatically emailed. My below code somehow worked one day but the next it stopped working with the error message saying that the 'To' parameter is invalid. I have a text label setup to test the concat statement and it is correct and I also have played around with the order of execution. Not sure how to fix this.

 

Below is the button.

 

Patch(
'Audit Listings', TemplateGalleryList1.Selected, {Current: false} );

 

Patch(
'Audit Listings',Defaults('Audit Listings'),{
Index: Index_DataCard1.Update,
Title: Title_DataCard1.Update,
Risk: Risk_DataCard2.Update,
Rating:{
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Value:DataCardValue34.Selected.Value,ID:DataCardValue34.Selected
},
'Recommendation Ref #': 'Recommendation Ref #_DataCard4'.Update,
Recommendation: Recommendation_DataCard4.Update,
'PSC Management Response': 'PSC Management Response_DataCard6'.Update,
'Responsible Officer': 'Responsible Officer_DataCard4'.Update,
'Original Completion Date': 'Original Completion Date_DataCard2'.Update,
'Revised Completion Date': 'Revised Completion Date_DataCard1'.Update,
Status:{
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Value:DataCardValue31.Selected.Value,ID:DataCardValue31.Selected
},
'Update/Comments': 'Update/Comments_DataCard4'.Update,
Owner:
DataCardValue9.SelectedItems
});

If(Toggle1.Value = true,
Office365Outlook.SendEmailV2(Concat(DataCardValue9.SelectedItems,Email , ";"),
Concatenate("New notification test " & DataCardValue26.Text),
"Here is the message body.",
{ Importance: "Normal" }
),
Notify("Email notification is turned off.")
);


If( // check for errors
!IsEmpty(
Errors('Audit Listings'
)
), // if true, show any error messages
Notify(
Concat(
Errors(
'Audit Listings'
), Column & ": " & Message
), NotificationType.Error
),
Notify(
"Your submission was accepted", NotificationType.Success

)
);

 

Navigate(AuditList);

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    154,447 Most Valuable Professional on at

    Hi @AlexWuhoo ,

    Cutting through everything else, the only relevant item here is the output of 

    Concat(
     DataCardValue9.SelectedItems,
     Email, 
     ";"
    )

    at the point the email code is executed. You have noted that it has been tested on a label and is correct. I am assuming here that DataCardValue9 (you might consider some control naming protocols here) is a Multi-select Combo Box based on a Person field and if the user list selected is by DisplayName rather than Email, one of the things that needs to be present is that the names are actually selected after the Form is opened and before the mail is sent - the first one is the most significant as the "selected" items will not include the email if the form is simply opened.

    If this is not the case, as a testing experiment (not really something I would do in production), put your Label on the screen with the code and refer to

    YourLabelName.Text

    in the To: parameter and see if that works (I am simply eliminating things happening in between).

     

     

     

  • AlexWuhoo Profile Picture
    on at

    Hi Warren,

     

    Thank you for getting back to me promptly. I will be taking your naming protocol advice and having it be something more clear. 

    I have been testing the app with the way you suggested and have the label on the same screen with the form. The Multi-select combo-box is based on a Person field in the Sharepoint list, and indeed every time the code is run the names are selected after the Form is opened and before the mail is sent. Everytime that a user is selected the Label updates showing their email separated by a semicolon.

    To add on, users open this form to update an activity so the fields of the form are populated from the item that the user has selected. If the field is already populated that should still mean that the names are still selected right?

  • AlexWuhoo Profile Picture
    on at

    I would also like to add that the SendEmailV2 method is also being used on another form that I have which is essentially the same but it is a blank form and users are just creating a new item. The users that are selected in that form receive the email notification.

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

    Hi @AlexWuhoo ,

    Are you saying the email sends correctly when the label content is referenced in the To: parameter ?

  • AlexWuhoo Profile Picture
    on at

    Sorry I hadnt fully understood what you meant in your original post. But yes, after I reference the Label.Text in my To:parameter the email was then able to be sent. Another thing is that the Subject line references the datavalue card of a Title column, and that is not sending with an email. Seems like directly referencing the values in the send email method is causing an issue.

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

    @AlexWuhoo ,

    You need to grab those two values in Variables before you submit the form, then use the Variables in the email code. Have a go and I will be happy to correct if necessary.

     

    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

  • AlexWuhoo Profile Picture
    on at

    Hi Warren,

     

    I tired to set the Variables however I still get the same issue.

    Set(auditTitle, DataCardValue26.Text);

    Set(recipients, Concat(DataCardValue9.SelectedItems,Email , ";"));

    Office365Outlook.SendEmailV2(recipients,
    Concatenate("New notification test " & auditTitle),
    "Here is the message body.",
    { Importance: "Normal" }
    );
  • WarrenBelz Profile Picture
    154,447 Most Valuable Professional on at

    @AlexWuhoo ,

    What values can you see in the Variables ?

  • AlexWuhoo Profile Picture
    on at

    @WarrenBelz 

    In the Set formulas it states that they have side effects and cannot be evaluated. 

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

    @AlexWuhoo ,

    Are you saying they do not set? What is the exact code (in text) you are using to set them?

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
wolenberg_ Profile Picture

wolenberg_ 119 Super User 2026 Season 1

#2
WarrenBelz Profile Picture

WarrenBelz 107 Most Valuable Professional

#3
Haque Profile Picture

Haque 103

Last 30 days Overall leaderboard