Welcome to WebmasterWorld Guest from 3.93.75.30

Forum Moderators: ocean10000

Message Too Old, No Replies

ASP Mail help

Trying to get ASP Mail to work

     
5:03 pm on Mar 21, 2009 (gmt 0)

New User

10+ Year Member

joined:May 13, 2005
posts: 7
votes: 0


Hello all,

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?

5:16 pm on Mar 21, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Sept 17, 2002
posts:2251
votes: 0


You seem to have defined Mailer twice.

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]

5:33 pm on Mar 21, 2009 (gmt 0)

New User

10+ Year Member

joined:May 13, 2005
posts: 7
votes: 0


Thanks for the help on the efficency issue, I'll take any suggestions out there!

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?

5:50 pm on Mar 21, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Sept 17, 2002
posts:2251
votes: 0


...

[edited by: GaryK at 5:55 pm (utc) on Mar. 21, 2009]

5:54 pm on Mar 21, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Sept 17, 2002
posts:2251
votes: 0


You're welcome.

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]

6:28 pm on Mar 21, 2009 (gmt 0)

New User

10+ Year Member

joined:May 13, 2005
posts: 7
votes: 0


Thank you SOOOO much for the help! It works now, and I now see what I was doing wrong. Thank you for helping someone foreign to code figure it out! You ROCK!
6:31 pm on Mar 21, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Sept 17, 2002
posts:2251
votes: 0


You're very welcome.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members