Forum Moderators: open
I'm trying to get ASP Mail to work on a Windows 2003 server, but am running into a roadblock.
When I send a form, the following error pops up:
Microsoft VBScript compilation error '800a0411' Name redefined /asp-test/confirmation.asp, line 11 DIM Mailer, strMsgHeader, qryItem, strMsgInfo I realize the message is telling me there's something wrong with the configuration with one of the variables, but which one is it and what is the issue?
The code I placed in a 'confirmation.asp' page looks like this:
DIM strEmail, strFirstName, strLastName, strSubject, strComments, Mailer
strEmail = request.form("Email")
strFirstName = request.form("FirstName")
strLastName = request.form("LastName")
strSubject = request.form("Subject")
strComments = request.form("Comments")
DIM Mailer, strMsgHeader, qryItem, strMsgInfo
Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.FromName = "ASP Web Pro Online"
Mailer.FromAddress= "torsionpro@hotmail.com"
Mailer.ReplyTo = strEmail
Mailer.RemoteHost = "mail-fwd"
Mailer.AddRecipient "John Blunda", "john@finestkindphoto.com"
Mailer.Subject = "ASP Web Pro Website: Online Form"
strMsgHeader = "This mail message was sent from the www.aspwebpro.com Online Form" & vbCrLf & vbCrLf
Mailer.BodyText = strMsgHeader & vbCrLf & "Email: " & Request.Form("Email") & _
vbCrLf & "First Name: " & Request.Form("FirstName") & _
vbCrLf & "Last Name: " & Request.Form("LastName") & _
vbCrLf & "Subject: " & Request.Form("Subject") & _
vbCrLf & "Comments: " & Request.Form("Comments")
IF Mailer.SendMail THEN
Response.Write strFirstName & ",<br>"
Response.Write "Your message has been successfully sent."
ELSE
Response.Write "The following error occurred while sending your message: " & Mailer.Response
END IF
%>] Any ideas?
ADDED: As an aside, you are assigning your form elements to variables in the first block of code, but then you're requesting the form elements again in the second block of code instead of using the variables. That is inefficient. I would suggest doing it this way:
Mailer.BodyText = strMsgHeader & vbCrLf & "Email: " & strEmail & _
vbCrLf & "First Name: " & strFirstName & _
vbCrLf & "Last Name: " & strLastName & _
vbCrLf & "Subject: " & strSubject & _
vbCrLf & "Comments: " & strComments
[edited by: GaryK at 5:23 pm (utc) on Mar. 21, 2009]
As for defining Mailer twice, as you can see, I've grabbed this free code from another website and am not sure what you mean. I see Mailer both in the first paragraph and second, but doesn't the code I see mean that it's defining the Mailer in the 1st, an calling on it in the 2nd?
Here's how I would modify the code to make it work. There's a bit more I would do, but let's keep it simple for now and get it working for you. The last line that I added, Set Mailer = Nothing is very important. :)
DIM strEmail, strFirstName, strLastName, strSubject, strComments, Mailer
strEmail = request.form("Email")
strFirstName = request.form("FirstName")
strLastName = request.form("LastName")
strSubject = request.form("Subject")
strComments = request.form("Comments")
Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.FromName = "ASP Web Pro Online"
Mailer.FromAddress= "torsionpro@example.com"
Mailer.ReplyTo = strEmail
Mailer.RemoteHost = "mail-fwd"
Mailer.AddRecipient "John Blunda", "john@example.com"
Mailer.Subject = "<Name of your website here> Online Form"
Mailer.BodyText = "This mail message was sent from the <Name of your website here> Online Form" & vbCrLf & vbCrLf & vbCrLf & "Email: " & strEmail & _
vbCrLf & "First Name: " & strFirstName & _
vbCrLf & "Last Name: " & strLastName & _
vbCrLf & "Subject: " & strSubject & _
vbCrLf & "Comments: " & strComments
IF Mailer.SendMail THEN
Response.Write strFirstName & ",<br>"
Response.Write "Your message has been successfully sent."
ELSE
Response.Write "The following error occurred while sending your message: " & Mailer.Response
END IF
Set Mailer = Nothing
ADDED: Examplified domain names as per TOS.
[edited by: GaryK at 5:58 pm (utc) on Mar. 21, 2009]