Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email automation with asp feedback form

Status
Not open for further replies.

caronlacy

Technical User
Sep 13, 2004
6
US
I have an asp feedback form that is supposed to email the results to a particular individual and post the results to an Access database on the server. Postting to the database works perfectly, but the email part isn't. I didn't write the code for the page, but from what little I know, it does contain the code to "trigger" the email. What components need to be in place for this process to work?

Thanks for your time.

Caron.
 
See if this would help you get going:


google.gif
juggle.gif

 
As long as FrontPage did not write the code, try this:

' send email via CDONTS using SMTP
Dim objCDONTS
Set objCDONTS = Server.CreateObject("CDONTS.NewMail")
objCDONTS.To = "jdoe@hotmail.com" 'accepts any email address
objCDONTS.From = "jdoe@hotmail.com"
objCDONTS.Subject = "Test CDONTS"
objCDONTS.Body = "This email sent via CDONTS"
objCDONTS.Send
Set objCDONTS = nothing
response.write "Email sent via CDONTS<br>
 
Actually, it was originally written with FrontPage. I've included the code below. This form has worked in the past, but we have recently installed a new webserver. The person responsible for this is no longer here, so I have the task of finding out what has broken and fixing it. :) Thanks to all for your help.


<%
' FP_ASP ASP Automatically generated by a Frontpage Component. Do not Edit.
On Error Resume Next

strErrorUrl = ""

If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
If Request.Form("VTI-GROUP") = "0" Then
Err.Clear

Set fp_conn = Server.CreateObject("ADODB.Connection")
FP_DumpError strErrorUrl, "Cannot create connection"

Set fp_rs = Server.CreateObject("ADODB.Recordset")
FP_DumpError strErrorUrl, "Cannot create record set"

fp_conn.Open Application("comments_ConnectionString")
FP_DumpError strErrorUrl, "Cannot open database"

fp_rs.Open "Results", fp_conn, 1, 3, 2 ' adOpenKeySet, adLockOptimistic, adCmdTable
FP_DumpError strErrorUrl, "Cannot open record set"

fp_rs.AddNew
FP_DumpError strErrorUrl, "Cannot add new record set to the database"
Dim arFormFields0(8)
Dim arFormDBFields0(8)
Dim arFormValues0(8)

arFormFields0(0) = "subject"
arFormDBFields0(0) = "subject"
arFormValues0(0) = Request("subject")
arFormFields0(1) = "email"
arFormDBFields0(1) = "email"
arFormValues0(1) = Request("email")
arFormFields0(2) = "comments"
arFormDBFields0(2) = "comments"
arFormValues0(2) = Request("comments")
arFormFields0(3) = "phone"
arFormDBFields0(3) = "phone"
arFormValues0(3) = Request("phone")
arFormFields0(4) = "subjectother"
arFormDBFields0(4) = "subjectother"
arFormValues0(4) = Request("subjectother")
arFormFields0(5) = "type"
arFormDBFields0(5) = "type"
arFormValues0(5) = Request("type")
arFormFields0(6) = "name"
arFormDBFields0(6) = "name"
arFormValues0(6) = Request("name")
arFormFields0(7) = "contact"
arFormDBFields0(7) = "contact"
arFormValues0(7) = Request("contact")

FP_SaveFormFields fp_rs, arFormFields0, arFormDBFields0

FP_SaveFieldToDB fp_rs, Now, "Timestamp"

fp_rs.Update
FP_DumpError strErrorUrl, "Cannot update the database"

fp_rs.Close
fp_conn.Close

Session("FP_SavedFields")=arFormFields0
Session("FP_SavedValues")=arFormValues0
Response.Redirect "thanks.asp"

End If
End If
 
The only other stuff I can think of is:

New webserver is 2003 vs. Old webserver is NT

SMTP service is installed on new webserver, but it wasn't when I started this troubleshooting. Is there any special config for this?
 
It wont work.....the reason is that FP uses WEBBOTS. Basically re-writes the code each time the page is loaded. So, what you can do is create a confirmation page and place the CDONTS code I placed above in your new conf page. That way when the form is run, and then submitted the confirmation page is loaded and kicks in the CDONTS. I know this works because I have done it many times.

Let me know how it goes.

-Joey
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top