Avatar of Didget
Didget
 asked on

Microsoft VBScript runtime error '800a01c2'

Hi
I get this message whenever I click on send in my form mailer.  I'm running an ASP form handler.

Microsoft VBScript runtime error '800a01c2'

Wrong number of arguments or invalid property assignment: 'SendMail'

/formhandler.asp, line 51

Here is my code:
<% Option Explicit %>
<% Response.buffer = true %>
<%
     Dim frmName, frmSurname, frmEmailAddy
     Dim frmPostalAddress, frmCountry, frmOtherCountry
     Dim frmTelephone, frmInterestIn, frmNumberPeople
     Dim frmDayArrive, frmMonthArrive, frmYearArrive
     Dim frmDayDepart, frmMonthDepart, frmYearDepart
     Dim frmComments
         
     frmName = Request.Form("Name")
     frmSurname = Request.Form("Surname")
     frmEmailAddy = Request.Form("Email")
     frmPostalAddress = Request.Form("PostalAddress")
     frmCountry = Request.Form("Country")
     frmOtherCountry = Request.Form("OtherCountry")
     frmTelephone = Request.Form("Telephone")
     frmInterestIn = Request.Form("InterestIn")
     frmNumberPeople = Request.Form("NumberPeople")
     frmDayArrive = Request.Form("DayArrive")
     frmMonthArrive = Request.Form("MonthArrive")
     frmYearArrive = Request.Form("YearArrive")
     frmDayDepart = Request.Form("DayDepart")
     frmMonthDepart = Request.Form("MonthDepart")
     frmYearDepart = Request.Form("YearDepart")
     frmComments = Request.Form("Comments")
     
     Dim emailBody
     
     emailBody = emailBody & "Name:" & frmName & vbCrLf
     emailBody = emailBody & "Surname:" & frmSurname & vbCrLf
     emailBody = emailBody & "Email:" & frmEmailAddy & vbCrLf
     emailBody = emailBody & vbCrLf
     emailBody = emailBody & "PostalAddress:" & frmPostalAddress & vbCrLf
     emailBody = emailBody & "Country:" & frmCountry  & vbCrLf
     emailBody = emailBody & "OtherCountry:" & frmOtherCountry & vbCrLf
     emailBody = emailBody & "Telephone:" & frmTelephone & vbCrLf
     emailBody = emailBody & "InterestIn:" & frmInterestIn & vbCrLf
     emailBody = emailBody & "NumberPeople:" & frmNumberPeople & vbCrLf
     emailBody = emailBody & "DayArrive:" & frmDayArrive & vbCrLf
     emailBody = emailBody & "MonthArrive:" & frmMonthArrive & vbCrLf
     emailBody = emailBody & "YearArrive:" & frmYearArrive & vbCrLf
     emailBody = emailBody & "DayDepart:" & frmDayDepart & vbCrLf
     emailBody = emailBody & "MonthDepart:" & frmMonthDepart & vbCrLf
     emailBody = emailBody & "YearDepart:" & frmYearDepart & vbCrLf
     emailBody = emailBody &  "Comments:" & frmComments & vbCrLf    
     
     'Response.Write("<TEXTAREA cols=80 rows=60>" & emailBody & "</TEXTAREA>")
     'Response.End
         
     SendMail frmEmailAddy, "martiniq@intekom.co.za, leanne@agnet.co.za", emailBody, 1
     Sub SendMail(sender, recipient, subject, body, importance)
     Response.Clear
     Response.Redirect("http://www.marina-martinique.co.za/thanks.htm")
     Dim mail
Set mail = CreateObject("CDONTS.NewMail")
     mail.MailFormat = 0     ' Mime
     mail.From = sender
     mail.To = recipient
     mail.Subject = subject
     mail.Body = body
     mail.Importance = importance
     mail.Send
     Set mail = Nothing
End Sub
%>

I cannot figure this one out. Please help.
Web Development

Avatar of undefined
Last Comment
COBOLdinosaur

8/22/2022 - Mon
AmericanDogma

Replace this line:

SendMail frmEmailAddy, "martiniq@intekom.co.za, leanne@agnet.co.za", emailBody, 1

WITH:

SendMail frmEmailAddy,"martiniq@intekom.co.za, leanne@agnet.co.za", SUBJECTVARIABLE, emailBody, 1


Where subject variables is the subject of the email. The sub routine is not receiving the correct number of parameters becuase you forgot to include the subject when you call the parameter and the subroutine is anticipatign that the subject is being pasted
webwoman

Move the response.clear and response.redirect to the LAST lines.

You also have no variables called sender, recipient, subject, body or importance. That's what the problem is.

Of course, unless you move those response.clear and response.redirect lines, nothing will be sent anyway.
AmericanDogma

webwoman the sub routine is being called just above the response.clear and response.redirect therfore the sub is called and then the response.cleared and redirected

The varibales you list do exist even though they were never declared. becuase they werent declared outsid eof the subroutine they are private not public variables which is fine.

Diget once again the error you are having is that there are not enoguh parameters beign passed to the subroutine. Your subroutien call needs to be reformed as:

SendMail frmEmailAddy,"martiniq@intekom.co.za, leanne@agnet.co.za", SUBJECTVARIABLE, emailBody, 1
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
webwoman

They have option explicit -- if they want to use a variable, it has to be declared. Not only are they NOT declared, they're never given any values.

If they're declared/set outside of the code posted, that was NOT specified.

They're not creating the mail object until AFTER the response.redirect. You can't send something if it never gets created.

And the error being generated has to do with the function, and the fact that the variables are NOT declared or set.
>>Wrong number of arguments or invalid property assignment: 'SendMail'
Didget

ASKER
Hi
when I put in SUBJECTVARIABLE, without any other changes I get this message:
Microsoft VBScript runtime error '800a01f4'

Variable is undefined: 'SUBJECTVARIABLE'

/formhandler.asp, line 51

I'm a bit confused about webwoman's comments. How would I apply this? Thanks for your help!
ASKER CERTIFIED SOLUTION
AmericanDogma

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
COBOLdinosaur

This question has been classified abandoned. I will make a recommendation to the
moderators on its resolution in a week or two. I appreciate any comments
that would help me to make a recommendation.

<note>
Unless it is clear to me that the question has been answered I will recommend delete.  It is possible that a Grade less than A will be given if no expert makes a case for an A grade. It is assumed that any participant not responding to this request is no longer interested in its final disposition.
</note>

If the user does not know how to close the question, the options are here:
https://www.experts-exchange.com/help/closing.jsp


Cd&

Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.