...

View Full Version : ASP Form using CDO - no email sending



annamjmi
06-25-2007, 10:06 PM
I am a CF programmer, but need to figure out how to send a form via ASP. All I need to do is submit a form. I downloaded the sendmail_cdo code from this website and it says it should work.

http://www.codeproject.com/asp/sendmail.asp

My form submits, but no email sends. Do I need to register something on the server? They are running Windows 2000 / Exchange 2000 and I have the SMTP if needed. What could be causing no emails to send. Again, I don't work with ASP so I am not getting far so any help would so be greatly appreciated.

Or could someone direct me to code that will work more easily?

miranda
06-26-2007, 11:48 PM
Here is one that I wrote that is a bit simpler to use.

This is easily altered just by changing the actual fields with the fields from your form.




Dim theMessage

theMessage = "First Name :" & RequestForm("FirstName") & "<br>" & _
"Last Name :" & RequestForm("LastName") & "<br>" & _
"Address :" & RequestForm("Address") & "<br>" & _
"City :" & RequestForm("City") & "<br>" & _
"State :" & RequestForm("State") & "<br>" & _
"Telephone :" & RequestForm("Telephone") & "<br>" & _
"Comments :" & RequestForm("Comments")


Call SendEmail(Request.Form("Recipient"), Request.Form("Sender"), Request.Form("EmailSubject"), theMessage)

Sub SendEmail(ByVal sTo, ByVal sFrom, ByVal sSubject, ByVal sMessage)
Dim oMail
Set oMail = Server.CreateObject("CDO.Message")
With oMail
.To = sTo
.From = sFrom
.Subject = sSubject
.HTMLBody = sMessage
'.TextBody = sMessage uncomment if you want to send a plain text email
End With
oMail.Send()
Set oMail = Nothing
End Sub

annamjmi
06-27-2007, 12:36 AM
Thank you. I used that code, but it brings up a http 500 internal error. Do I need some sort of configurations?

miranda
06-27-2007, 07:31 PM
Turn your friendly errors off in your browser settings, this will display the error. Then you can post the error so that we can see what the problem is.

in IE tools > Internet Options > click the Advanced tab >under the Browsing category scroll down to Show friendly HTTP error messages and uncheck it

annamjmi
06-27-2007, 07:42 PM
Thank you.

I got this error:

Microsoft VBScript runtime error '800a000d'

Type mismatch: 'RequestForm'

/sendmail3.asp, line 4

miranda
06-27-2007, 07:49 PM
oops my errror . thats what happens when I use cut/paste. typos get carried over. grrrr. use this code instead of the first example



Dim theMessage

theMessage = "First Name :" & Request.Form("FirstName") & "<br>" & _
"Last Name :" & Request.Form("LastName") & "<br>" & _
"Address :" & Request.Form("Address") & "<br>" & _
"City :" & Request.Form("City") & "<br>" & _
"State :" & Request.Form("State") & "<br>" & _
"Telephone :" & Request.Form("Telephone") & "<br>" & _
"Comments :" & Request.Form("Comments")


Call SendEmail(Request.Form("Recipient"), Request.Form("Sender"), Request.Form("EmailSubject"), theMessage)

Sub SendEmail(ByVal sTo, ByVal sFrom, ByVal sSubject, ByVal sMessage)
Dim oMail
Set oMail = Server.CreateObject("CDO.Message")
With oMail
.To = sTo
.From = sFrom
.Subject = sSubject
.HTMLBody = sMessage
'.TextBody = sMessage uncomment if you want to send a plain text email
End With
oMail.Send()
Set oMail = Nothing
End Sub

annamjmi
06-27-2007, 08:26 PM
coolio... The form submits with no error, but now I don't get the email sent. I read somewhere you need to have something configured?

annamjmi
06-27-2007, 08:33 PM
Nevermind!!! It worked!!! Thanks!!!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum