[thelist] ASP and form question

lon.kraemer lwkraemer at directvinternet.com
Mon Jul 8 12:26:02 CDT 2002


Hi Sharon,

Please DELETE and forget the script that headlemur sent you. It'll only
confuse you at this point. He showed that to me about 5 years ago. I
told him it was overkill then. It still is! No offense intended Alan ;)

Here is a VERY simple[0] example that should get you going using the
CDONTS.NewMail object:

Save this as form.html
------------
<html>
<head>
<title>form.html</title>
</head>
<body>
<form action="processform.asp" method="post">
Full Name: <input type="text" name="fullname"><br>
Email Address: <input type="text" name="emailaddress"><br>
Message:<br>
<textarea cols="40" rows="4" name="message"></textarea><br>
<input type="submit">
</form>
</body>
</html>
-------------

Save this as processform.asp
-------------
<%
Dim fromname,fromemail,frommessage,objMail,strBody
fromname=request.form("fullname")
fromemail=request.form("emailaddress")
frommessage=request.form("message")
Set objMail = Server.CreateObject("CDONTS.NewMail")
objMail.From = fromemail
objMail.To = "Sharon F. Malone<sharon at herdomain.com>"
objMail.Subject = "Form response email"

strBody = "Name: " & fromname & vbCrLf
strBody = strBody & "...whose email is: " & fromemail & vbCrLf
strBody = strBody & "...said: " & frommessage & vbCrLf

objMail.Body = strBody
objMail.Send
Set objMail = Nothing 'You must always do this with CDONTS.
Response.Redirect("thanks.html")
 %>
------------

Save this as thanks.html
------------
<html>
<head>
<title>thanks.html</title>
</head>
<body>
Your email has been sent.
</body>
</html>
-------------

[0] This uses three separate pages, but could easily be just a single
page. There is no form validation or object error handling. It uses
minimal object methods.

You might also just be well advised to Google "CDONTS" for more complete
info.

HTH
--
Lon Kraemer
-----------------------------------------






More information about the thelist mailing list