ASP Email Form

OJM

Perch
I apologise if this has been posted before, but I did a quick search and couldn't find an answer.

I have an email form on my website, which worked on my old host, but doesn't seem to work here (which was expected due to server changes etc), and wondered if anyone could take a look at it for me please, and tell me where I'm going wrong;


Code:
<%
If Request.Form("btnSubmit").Count > 0 Then
' Create the message for the email
strMessage = "<html><head></head><body bgcolor=#000000>"
strMessage = strMessage & "<font face=verdana,arial size=3 color=#CC0000>"
strMessage = strMessage & "<b>Proud To Have Met You<br />&nbsp;&nbsp;&nbsp;- Contact Form</b><br /><br />"
strMessage = strMessage & "</font>"
strMessage = strMessage & "<font face=verdana,arial size=2 color=#FFFFFF>"
strMessage = strMessage & "Name : " & Request.Form("name") & "<br />"
strMessage = strMessage & "Email : " & Request.Form("email") & "<br />"
strMessage = strMessage & "Subject : " & Request.Form("subject") & "<br /><br />"
strMessage = strMessage & "Info : " & Request.Form("info") & ""
strMessage = strMessage & "</font>"
strMessage = strMessage & "</body></html>"
' Create email object and set all the values, setting the from address to be the person who filled in the form
Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.FromName = Request.Form("name")
Mailer.FromAddress= Request.Form("email")
Mailer.RemoteHost = "mail.domainname.co.uk"
Mailer.AddRecipient = "Proud To Have Met You", [email="[email protected]"][email protected][/email]
Mailer.Subject	= "Proud To Have Met You - Contact Form"
Mailer.ContentType = "text/html"
Mailer.BodyText = strMessage
' Send the mail and tidy up
if Mailer.SendMail then
' Redirect to thankyou page
Response.Redirect "thankyou.htm"
else
 
Response.Write "Mail send failure. Error was " & Mailer.Response
End If
End If
%>


Using the above, the following error is shown;


Code:
Microsoft VBScript compilation [font=Arial][size=2]error '800a0401'[/size][/font]
 
[font=Arial][size=2]Expected end of statement[/size][/font] 
 
[font=Arial][size=2]/email.asp[/size][/font][font=Arial][size=2], line 22[/size][/font] Mailer.AddRecipient = "Proud To Have Met You", [email="[email protected]"][email protected][/email]
------------------------------------------------------------^


So I removed part of the problem, so it read;


Code:
Mailer.AddRecipient = [email="[email protected]"][email protected][/email]


Now I receive this;


Code:
Microsoft VBScript runtime [font=Arial][size=2]error '800a01b6'[/size][/font]
 
[font=Arial][size=2]Object doesn't support this property or method: 'Mailer.AddRecipient'[/size][/font]
[font=Arial][/font] 
[font=Arial][size=2]/email.asp[/size][/font][font=Arial][size=2], line 22[/size][/font]


Thanks in advance!

Oli
 
I did not see anything where it sent the password to the remote server:
ailer.FromName = Request.Form("name")
Mailer.FromAddress= Request.Form("email")
Mailer.RemoteHost = "mail.domainname.co.uk"
Mailer.AddRecipient = "Proud To Have Met You", [email protected]
Mailer.Subject = "Proud To Have Met You - Contact Form"
Mailer.ContentType = "text/html"
Mailer.BodyText = strMessage


It will need to send the password with SMTP Auth.
 
Code:
Mailer.AddRecipient = "Proud To Have Met You", [email][email protected][/email]
All the varieties I've seen here are incorrect. In fact it's impossible that this used to work at your old host ;)

This should be:
Code:
Mailer.AddRecipient "Proud To Have Met You", "[email protected]"

Note the absence of the 'equals' sign. It's not a property, but a method. You also need double quotes around string literals such as an email address.
 
Sound as a pound!

Thank you very much for your help!



If anyone is interested, this code works;


Code:
<%
If Request.Form("btnSubmit").Count > 0 Then
' Create the message for the email
strMessage = "<html><head></head><body bgcolor=#000000>"
strMessage = strMessage & "<font face=verdana,arial size=3 color=#CC0000>"
strMessage = strMessage & "<b>Proud To Have Met You<br />&nbsp;&nbsp;&nbsp;- Contact Form</b><br /><br />"
strMessage = strMessage & "</font>"
strMessage = strMessage & "<font face=verdana,arial size=2 color=#FFFFFF>"
strMessage = strMessage & "Name : " & Request.Form("name") & "<br />"
strMessage = strMessage & "Email : " & Request.Form("email") & "<br />"
strMessage = strMessage & "Subject : " & Request.Form("subject") & "<br /><br />"
strMessage = strMessage & "Info : " & Request.Form("info") & ""
strMessage = strMessage & "</font>"
strMessage = strMessage & "</body></html>"
' Create email object and set all the values, setting the from address to be the person who filled in the form
Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.FromName   = Request.Form("name")
Mailer.FromAddress= Request.Form("email")
Mailer.RemoteHost = "localhost"
Mailer.AddRecipient "Proud To Have Met You", "[email="[email protected]"][email protected][/email]"
Mailer.Subject	= "Proud To Have Met You - Contact Form"
Mailer.ContentType = "text/html"
Mailer.BodyText   = strMessage
' Send the mail and tidy up
if Mailer.SendMail then
' Redirect to thankyou page
Response.Redirect "thankyou.htm"
else
  
Response.Write "Mail send failure. Error was " & Mailer.Response
End If
End If
%>
 
Quick question...

What's the preferred email component to use for sending bulk newsletters (1,000+) through an ASP script (Web Wiz Mailing List)?
 
CDOSYS works well, but please make sure oyu have signed the mass mail authorization form so you do not get limited.
 
Yeah, I've signed and sent in the mass mail form (but I haven't had any confirmation).

However, I've just sent 1,000+ emails using ASPMail, so I think the limit has been taken off.

Thanks for your help!
 
Ah, problem...what do I use as the username and password for the auth?

I've tried my email address for the username, and my password, but it's throwing up an error like it's not accepting them;


Code:
[font=Arial]error '8004020f'[/font] 
 
[font=Arial][size=2]/emo_mail/functions/functions_send_mail.asp[/size][/font][font=Arial][size=2], line 235[/size][/font]



Line 235 is the second to last line here;


Code:
   With objCDOSYSMail 
	'Who the e-mail is from
	.From = """" & strWebsiteName & """ <" & strWebsiteEmailAddress & ">"""
	   
	'Who the e-mail is sent to
	.To = """" & strToName & """ <" & strEmailAddress & ">"""
		 
	'The subject of the e-mail
	.Subject = strSubject
	   
	'Set the e-mail body format (HTMLBody=HTML TextBody=Plain)
	If strMailFormat = "HTML" Then
	  .HTMLBody = strEmailBody & strAppendToEmail
	Else
	 .TextBody = strEmailBody & strAppendToEmail
	End If
	   
	'Send the e-mail
	If NOT strMailServer = "" Then .Send
   End with
 
Yeah I'm using the full email address. I can access this fine through Outlook, but when I put the same email address and password into the newsletter, it won't send.
 
When you are using localhost you don't need it, only when using a remote mail server, I just looked over your script and saw you had localhost.
 
Back
Top