Forum Discussion
Help with this error. method 'SendEmailV2' has an invalid value for parameter 'To'
So i have a label which the email refers to but now for some reason it is throwing this error. Office365Outlook.SendEmailV2(Label4.Text,"A Learning request has been lodged") And in the label4, I have a series of nested ifs like this: If(DataCardValue3.Selected.Value = "Coaching Request", "[email protected]", If(DataCardValue3.Selected.Value = "Training Request", "[email protected]", If(DataCardValue3.Selected.Value = "General Request", "[email protected]"))) Any ideas on what I am doing wrong?
5 Replies
- Syndicate_AdminAdministrator
Hi @Philmack ,
Please try this:
If(!IsBlank(DataCardValue3.Selected), Office365Outlook.SendEmailV2(Label4.Text,"A Learning request has been lodged") ) And in the label4, I have a series of nested ifs like this: If(DataCardValue3.Selected.Value = "Coaching Request", "[email protected]", "Training Request", "[email protected]", "General Request", "[email protected]")Best Regards,
Wearsky
- Syndicate_AdminAdministrator
I'd agree with @v-xiaochen-msft's suggestion but streamline the if statement in Label4 to use a Switch instead - especially if you have to add more scenario's in future
Switch(DataCardValue3.Selected.Value, "Coaching Request", "[email protected]", "Training Request", "[email protected]", "General Request", "[email protected]") - Syndicate_AdminAdministrator
I've change the label to Switch as mentioned above but it is still throwing the error.
method 'SendEmailV2' has an invalid value for parameter 'To' below is the code that it is outlining as the issue.
Office365Outlook.SendEmailV2(Label4.Text,"A Learning request has been lodged")
- Syndicate_AdminAdministrator
Are there any instances where Label4.Text is blank? A blank 'To' parameter of the SendEmailV2 action would cause an error.
You can extend a Switch statement to have a default value if no other clauses are met. I should have added it previously, apologies.Switch(DataCardValue3.Selected.Value, "Coaching Request", "[email protected]", "Training Request", "[email protected]", "General Request", "[email protected]", "[email protected]")
Else, feel free to post an image of the error and will see if I can help further. - Syndicate_AdminAdministrator
Yeah so the fix was just having the one if in the label so Wearsky you da champ!