|
If you use Microsoft frontpage, there is built in form-emailing
facility for that (the Form Properties wizard generates special
'webbot' tags for you. If you need some help, tell us
the form's name and where
you want to e-mail it, we can
advise you.
We do not have a 'standard' script that can mail just any
form's data, anywhere, because hackers tend to find these
and use them to mail to the world.
However, we can suggest the following 'asp' script that can be
edited to
send form data to a specific e-mail address.
Scripts that can send 'any' data to a specific email address look
like the following.
Put the following in a file such as sendformemail.asp
and make that the ACTION of the form.
-------------------
<!--METADATA TYPE="typelib" UUID="CD000000-8B95-11D1-82DB-00C04FB1625D"
NAME="CDO for Windows Library" -->
<!--METADATA TYPE="typelib" UUID="00000205-0000-0010-8000-00AA006D2EA4"
NAME="ADODB Type Library" -->
<%
Dim buildbody
dim errorfound
buildbody = "E-mail form data submitted from website" & Chr(13) &
Chr(10)
buildbody = buildbody & Chr(13) & Chr(10)
for each fld in Request.Form
buildbody = buildbody & fld & ":" & Request.Form(fld) & Chr(13) &
Chr(10)
Response.write("<br>" & fld & ":" & Request.form(fld))
next
buildbody = buildbody & Chr(13) & Chr(10)
Dim objFields
Dim objCfg
Dim objMsg
Set objCfg = Server.CreateObject("CDO.Configuration")
Set objMsg = Server.CreateObject("CDO.Message")
Set objFields = objCfg.Fields
objFields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")
= cdoSendUsingPort
objFields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")
= "mail.thehostingservice.com"
objFields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout")
= 10
objFields.Update
Set objMsg.Configuration = objCfg
With objMsg
.To = "yourmailbox@yourdomain.com"
.From = "yourdomain formmail <yourmailbox@yourdomain.com>"
.Subject = "Form Data - whatever"
.TextBody = buildbody
.Send
End With
'Cleanup
Set ObjMsg = Nothing
Set objCfg = Nothing
Set objFields = Nothing
Response.Redirect Request("thankyou.htm")
%>
-------------------
But with the above script, you can't predict the order of the
fields
that get embedded in the e-mail because it just takes it in the
order it is received
from the browser and often appears random.
It is better to edit the script to format the e-mail the way you
want and to
send specific form fields in a certain order, so building the
body of the message would be something like the following,
where the fields match the names of the form elements.
Replace the green code in the section above with code like:
fld = "fullname"
buildbody = buildbody & fld & ": " & Request.Form(fld) & Chr(13) &
Chr(10)
fld = "address"
buildbody = buildbody & fld & ": " & Request.Form(fld) & Chr(13) &
Chr(10)
fld = "city"
buildbody = buildbody & fld & ": " & Request.Form(fld) & Chr(13) &
Chr(10)
.
.
.
And
so on.
|