cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Power apps not accepting code to send email

vm.png

Hi Guys,

 

I'm fairly new to Power Apps. I'm not too sure why I keep getting my code in red underline?

Error says: invalid number of arguments, received 2, expected 3-4

 

Can I please get some help in understanding what went wrong?

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

@Jas91 ,

That is why I asked for the Items property of the drop-down. It is actually nothing to to with the drop-down, but rather the field type it is writing back to (which is reflected in the Items and cannot be Text or the code would work). I am going to take a guess that it is a Lookup field and you will need this.

Form1.LastSubmit.'Meeting With'.Value

PS I see you are over the ditch - I am from CQ Oz.

 

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.

 

View solution in original post

10 REPLIES 10
Highlighted
Super User III
Super User III

HI @Jas91 ,

You do not need the {} brackets, nor the Subject: or Body: tags. Just put the parameters separated by commas. You also have an extra unneeded comma after the closing bracket.

If you had posted it as Text, I could have corrected it for you.

 

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.

 

 

 

Highlighted

Hi @WarrenBelz 

 

Thanks for the tip I tried it but still get an error. 

 

Error: The function 'sendmail' has some invalid arguments.

 

Code:

 

UpdateContext({varSubmit:false});
Office365Outlook.SendEmail(Form1.LastSubmit.'Meeting With',

"Visitor at reception" & Form1.LastSubmit.'Visitor Name',
"<strong>Dear Team <br/><br/> There is a visitor for you <br/><br/>
<tablewidth= '100%' border= '1' cellpadding= '5' style='border:1px solid black; border-collapse'>" & "<tr style='background-color:#efefef'>
<th style='text-align:left'>Visitor Name</th><th style='text-align:left'>Company Name</th><th style='text-align:left'>Email</th><th style='text-align:left'>Contact Number</th><th style='text-align:left'>Date</th> <tr>
<td>" & Form1.LastSubmit.'Visitor Name' & "</td>
<td>" & Form1.LastSubmit.'Company Name' & "</td>
<td>" & Form1.LastSubmit.Email & "</td>
<td>" & Form1.LastSubmit.'Contact Number' & "</td>
<td>" & Form1.LastSubmit.'Date and time' & "</td> </tr>"
);(NewForm(Form1);

 

Thanks,

Highlighted

Hi @Jas91 ,

You had a bracket before NewForm.

The below is valid syntax assuming that Form1.LastSubmit.'Meeting With' is a valid email address.

Note you need to use V2 to automatically recognize HTML and I have not checked your HTML for structure (although this will not stop it sending).

UpdateContext({varSubmit:false});
Office365Outlook.SendEmailV2(
   Form1.LastSubmit.'Meeting With',
   "Visitor at reception" & Form1.LastSubmit.'Visitor Name',
   "<strong>Dear Team <br/><br/> There is a visitor for you <br/><br/>
   <tablewidth= '100%' border= '1' cellpadding= '5' style='border:1px solid black; border-collapse'>" & "<tr style='background-color:#efefef'>
   <th style='text-align:left'>Visitor Name</th><th style='text-align:left'>Company Name</th><th style='text-align:left'>Email</th><th style='text-align:left'>Contact Number</th><th style='text-align:left'>Date</th> <tr>
   <td>" & Form1.LastSubmit.'Visitor Name' & "</td>
   <td>" & Form1.LastSubmit.'Company Name' & "</td>
   <td>" & Form1.LastSubmit.Email & "</td>
   <td>" & Form1.LastSubmit.'Contact Number' & "</td>
   <td>" & Form1.LastSubmit.'Date and time' & "</td> </tr>"
);
NewForm(Form1);

 

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.

 

Highlighted

Hi @WarrenBelz 

 

I copied it word for word and it still says

Error 'The function sendmailv2 has some invalid arguments.

Do you think it's to do with the Form1.lastSubmit.'Meeting with'? That combo box is just a drop down with email options. 

v2.png

Highlighted

@Jas91 ,

Yes, I copied it back here with other values and it is valid. There is something wrong with one or more of your Form1.LastSubmit.xxxx entries.

 

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.

Highlighted

Hi @WarrenBelz 

 

Thanks for your help, that makes sense. So when I hover over the 'Meeting With' it shows me the error

er.png

 

It's looking for a text entry, however 'Meeting With'  is a dropdown box with email addresses to pick from. 

Would you know if there is different formatting for dropdown boxes?

 

Regards,

Highlighted

@Jas91 ,

What are the Items of the drop-down?

 

Highlighted

@WarrenBelz 

 

It's basically just a set of email addresses. I think i've narrowed down the problem. if I change "meeting with" with just a text box where I type the email in the form it works fine. It just doesn't seem to like it if I keep it as a dropdown box.

 

But I would really like it to be a drop down box so users can select an email already listed.

 

UpdateContext({varSubmit:false});
Office365Outlook.SendEmailV2(
   Form1.LastSubmit.email,

'Meeting With' drop down box

era.png

Highlighted

@Jas91 ,

That is why I asked for the Items property of the drop-down. It is actually nothing to to with the drop-down, but rather the field type it is writing back to (which is reflected in the Items and cannot be Text or the code would work). I am going to take a guess that it is a Lookup field and you will need this.

Form1.LastSubmit.'Meeting With'.Value

PS I see you are over the ditch - I am from CQ Oz.

 

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.

 

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (7,682)