Example ASP script for sending formmail
(uses Jmail)
First create your form page:
Form.asp :
<html>
<head>
<title>emailform</title>
</head>
<body>
<form method="post" action="SendMail.asp">
Name <INPUT name="name" type="text"><br>
Email<INPUT name="Email" type="text"><br>
Company<INPUT name="company" type="text"><br>
Occupation <SELECT name="state">
<OPTION value="coder">Coder
<OPTION value="coder">Hacker
<OPTION value="coder">Developer
<OPTION value="coder">Guru
</SELECT><BR>
Favorite TV-show<TEXTAREA name="tv-show"></TEXTAREA>
<br>
<INPUT type="submit" value="Send">
</form>
</body>
</html>
Now create your mail script page:
Sendmail.asp
<%
Response.Buffer = True
Set JMail = CreateObject("JMail.SMTPMail")
JMail.ServerAddress = "smtp.yourdomain"
JMail.Sender = "formresponse@yourdomain"
Jmail.AddRecipient "sales@yourdomain"
JMail.Subject = "Form Response"
FOR EACH el IN Request.Form
body = body & el & ": " & Request.form(el) &
vbcrlf
NEXT
JMail.Body = Body
JMail.Priority = 1
JMail.Execute
Set JMail = Nothing
' The message has been sent - redirect to confirmation page
response.redirect "successfulpage.asp"
%>
This script will work on all forms with as many fields as you wish.
Parts in red italics need to be changed to suit
your needs .
Full details on how to use Jmail can be found
here top
Example ASP script for password
protecting pages
To password protect a directory you can use the following method:
Create a page called index.asp as follows (replace guest
and login with your own username and
password)
<%
msg = ""
If Request("Submit")<>"" Then
If Request("username") = "guest"
and Request("password")="login"
Then
Session("Valid") = Request("username")
response.redirect "nextpage.asp"
'first protected page here
Else msg = "Invalid username or
password. Try again!"
End If
End If
%>
<html><head><title>Password
Protect</title></head>
<body><form action="index.asp"
method="post"><table>
<%If msg <> "" Then%>
<tr> <td colspan="2"><font color=red><%=msg%></font></td></tr>
<%End If%>
<tr> <td>UserName:</td> <td><input
type="text" name="UserName"></td></tr>
<tr><td>Password:</td> <td><input
type="Password" name="Password"></td></tr>
<tr><td colspan="2"><input
type="submit" name="Submit"></td></tr>
</table></form></body></html>
On top of every ASP page you want to protect in the directory add the
following function to the very top of the page:
<%If Session("Valid") = ""
Then
Response.redirect "index.asp"
End If%>
Any page with this in it will not allow the user to view it unless they
are logged in!
Parts in red italics need to
be changed to suit your needs . top
Back to Support Index