|
Creating online forms -ASPMail Each website hosted on AAPT's web servers has the ability to send Email from a web page. This
is commonly used in applications where the web page vendor would like to recieve "feedback" or for
basic online ordering/contact forms. ASPMail Information.
"AspMail is used on more ASP installations than any other commercial or free product. Used on 1000's of Web sites around the world, this component allows you to send SMTP mail directly from a Web page. Versions 2.5x and > are 2-3 times faster than previous versions and have very low CPU utilization." AspMail includes support for
Working example code:To make these scripts work, all you need to do is save the two files to a section of your website, change the sections in green to have "real" information, and then load "myform.asp" in a webbrowser.
<%
' change these to reflect where form should go
fromName="The _From_ Name here"
fromAddress="sender@domain.com.au"
toName="The _to_ name here"
toAddress="recipient@domain.com.au"
subject="Put your subject here"
relay="ntmailhost.hosting.connect.com.au"
%>
<html>
<head>
<title>FormToBeMailed.asp</title>
</head>
<body>
<form action="mailrespond.asp" method="GET">
This is a demonstration form:<br>
First Name : <input NAME="NameFirst" size="10"><br>
Last Name : <input NAME="NameLast" size="10"><br>
Country : <input NAME="Country" value="Australia" size="30"><br>
State : <input NAME="State" MaxLength="2" size="3"><br>
email copy to : <input NAME="emailcopy" MaxLength="20" size="40"><br>
<input type="submit"><input type="reset">
<% ' do not touch these lines. Needed to send mail! %>
<input type="hidden" name="mail-from" value="<%=fromName%>">
<input type="hidden" name="mail-fromAddress" value="<%=fromAddress%>">
<input type="hidden" name="mail-to" value="<%=ToName%>">
<input type="hidden" name="mail-toaddress" value="<%=toaddress%>">
<input type="hidden" name="mail-subject" value="<%=subject%>">
<input type="hidden" name="mail-relay" value="<%=relay%>">
</form>
</body>
</html>
-= The responder code =- (mailrespond.asp)
<html><head>
<title>mailrespond.asp</title>
</head><body bgcolor="#FFFFFF">
<%
' ASPMail(tm) from http://www.serverobjects.com
' is not part of ASP per se,
my_from=request("mail-fromName")
my_fromAddress=request("mail-fromaddress")
my_to=request("mail-toName")
my_toAddress=request("mail-toaddress")
my_subject=request("mail-subject")
my_relay=request("mail-relay")
Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.RemoteHost = my_relay
Mailer.FromName = my_from
Mailer.FromAddress = my_fromAddress
Mailer.AddRecipient my_to, my_toaddress
Mailer.Subject = my_subject
for each whatever in request.querystring
If instr(whatever,"mail-")=0 then
Mailer.BodyText = whatever & "=" & vbcrlf
Mailer.BodyText = request.querystring(whatever) & vbcrlf & vbcrlf
end if
next
for each whatever in request.form
If instr(whatever,"mail-")=0 then
Mailer.BodyText = whatever & "=" & vbcrlf
Mailer.BodyText = request.form(whatever) & vbcrlf & vbcrlf
end if
next
my_emailcopy=request("emailcopy")
If my_emailcopy="" then
else
Mailer.AddRecipient "form filler",my_emailcopy
end if
If Mailer.SendMail then
Msg = "mail sent sucessfully!"
Else
Msg = "mail was not sent sucessfully"
End If
response.write Msg
Response.Write(Mailer.Response)
%>
</body>
</html>
|
| Copyright © AAPT Limited |
|