Generic Email Form HandlerNote: SMTP must be installed on the server for this to work. If you get an error saying the object couldn't be created, its because SMTP isn't installed on the system. In that case, check with the system administrator to see if there's an email component installed on the server or if you can get one installed. One such email component is ASP QMail - see the ASP QMail script for a sample ASP QMail script.
<%
If request.form("Comments")="" then
response.write "<p><br><center><font face='arial' size=3>"
response.write "<b>Please don't forget to enter your"
response.write " comments or question!</b></font>"
response.write "<form>"
response.write "<input type=""button"" value=""Return to Form"""
response.write " onclick=history.go(-1)></form>"
response.end
End If
' this is where we package up the information for the body of then
' message using the variable named Message and a For...Next statement
' that grabs each item passed from the form. This example returns all the
' form fields in their proper tab order by using keys.
' The vbCrLf is a carriage return/line feed; its there to add line breaks
' to the completed email message.
for i=1 to request.form.count
Message = Message & request.form.key(i) & ": " & request.form.item(i) & vbCrLf
Next
' now we'll create the mail object and fill in the
' various email fields
Set objMail = CreateObject("CDONTS.Newmail")
objMail.From = request.form("Email")
objMail.To = "kathi@attitude.com"
objMail.Subject = "ASP Site Form Submission"
objMail.Body = Message
objMail.Send
Set objMail = Nothing
' now add confirmation that the mail was sent and/or other
' scripting as desired
%>
|