web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

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
    153,541 Most Valuable Professional on at

    @AlexWuhoo ,

    That does not make sense to me, so it is a bit hard to respond other than to say it should work. You can try this

    If(
     Toggle1.Value,
     With(
     {
     wTo:
     Concat(
     DataCardValue9.SelectedItems,Email, 
     ";"
     ),
     wAudit: DataCardValue26.Text
     },
     Office365Outlook.SendEmailV2(
     wTo,
     "New notification test " & wAudit
     "Here is the message body.",
     )
     ),
     Notify(
     "Email notification is turned off.",
     NotificationType.Information
     )
    );
    

    but I am not sure I can offer too much more.

     

    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

    Placing just the Set function on a separate button and then having recipients be on a label is working as the email address appears on the label. I also tried having the label refer to recipients in the original button but that does not work. Seems like having the Set function amongst the patch function is causing issues.

  • WarrenBelz Profile Picture
    153,541 Most Valuable Professional on at

    @AlexWuhoo ,

    Just concentrate on this one - put this on a button

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

    and this on a label

    recipients

    If you do not see the expected emails in the label after you select the button, you need to look at why.

     

  • AlexWuhoo Profile Picture
    on at
    Set(auditTitle, DataCardValue26.Text);

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


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

    It appears that the set functions aren't working right now. This is the code i used to set the variables and call on them in the SendEmail function. It comes after the Patch function as seen in my original post.

  • WarrenBelz Profile Picture
    153,541 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?

  • AlexWuhoo Profile Picture
    on at

    @WarrenBelz 

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

  • WarrenBelz Profile Picture
    153,541 Most Valuable Professional on at

    @AlexWuhoo ,

    What values can you see in the Variables ?

  • 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
    153,541 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

    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.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
Kalathiya Profile Picture

Kalathiya 422

#2
WarrenBelz Profile Picture

WarrenBelz 380 Most Valuable Professional

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 325 Super User 2025 Season 2

Last 30 days Overall leaderboard