Microsoft VBScript runtime error '800a01c2'

Posted on 2003-02-24
Medium Priority
Last Modified: 2007-12-19
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>")
     SendMail frmEmailAddy, "martiniq@intekom.co.za, leanne@agnet.co.za", emailBody, 1
     Sub SendMail(sender, recipient, subject, body, importance)
     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
     Set mail = Nothing
End Sub

I cannot figure this one out. Please help.
Question by:Didget
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 8008554
Replace this line:

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


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
LVL 19

Expert Comment

ID: 8010665
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.

Expert Comment

ID: 8010918
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
Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

LVL 19

Expert Comment

ID: 8012814
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'

Author Comment

ID: 8014758
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!

Accepted Solution

AmericanDogma earned 100 total points
ID: 8017190
You need to declare the subjectvarioable using

DIM subjectvariable

Also you should be sure to set the subjectvariabel to whatever your email subject is like:

subjectvariable = "here is my emails subject"

You also need to do that for the emailBody variable l;ike:

emailbody = "This is my email body"

LVL 19

Assisted Solution

webwoman earned 100 total points
ID: 8019925
Frankly, I would get rid of the subroutine -- it's completely unnecessary.

After you load all the variables, I'd do this...

    Dim mail
Set mail = CreateObject("CDONTS.NewMail")
    mail.MailFormat = 0     ' Mime
    mail.From = frmEmailAddy
    mail.To = recipient (who IS this going to?)
    mail.Subject = subject (what do you want to use?)
    mail.Body = emailBody
    mail.Importance = importance (look it up -- I think it's a number)
    Set mail = Nothing

Then the response.redirect

It's not clear who it's going to, what the subject should be, or how you're setting the importance. If you want those email addresses to be the TO, they need to be separated with a SEMICOLON, not a comma, and you never DO have a subject.
LVL 53

Expert Comment

ID: 9350216
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.

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.

If the user does not know how to close the question, the options are here:



Featured Post

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question