Another simple and very valuable tool to add to your website is an Email This Page option. In this example, you can allow users to send the URL of any page within your website to any email address they choose. For our purposes, we will use ASPMail for sending mail.
First, place this link on your home page:
<a href="../emailthispage.asp">Email This Page</a>
Next, create a page called /EmailThisPage.asp and paste the following code:
<form action="emailthispageconfirm.asp" method="post" name="Emailthispage">
<%
DIM strURL
strURL = Request.ServerVariables("HTTP_Referer")
IF strURL = "" THEN
Response.Write "Sorry, your browser does not support this function."
END IF
%>
<p><b>Page Link:</b> <%= strURL %></p>
<table width="100%" border="0">
<tr><td width="25%"><div align="right">Your Email:</div></td>
<td width="75%"><input type="text" name="YourEmail" size="40"></td></tr>
<tr><td width="25%"><div align="right">Your First Name:</div></td>
<td width="75%"><input type="text" name="YourName" size="40"></td></tr>
<tr><td width="25%"><div align="right">Recipient's Email:</div></td>
<td width="75%"><input type="text" name="RecipEmail" size="40"></td></tr>
<tr><td width="25%"><div align="right">Recipient's First Name:</div></td>
<td width="75%"><input type="text" name="RecipName" size="40"></td></tr>
</table>
<table width="100%" border="0">
<tr><td>Comments:</td></tr>
<tr><td><textarea name="Comments" cols="50"></textarea></td></tr>
</table>
<input type="hidden" name="URL" value="<%= strURL %>">
<input type="submit" value="Submit">
</form>
Last, create a confirmation page called /EmailThisPageConfirm.asp, paste the following code, and customize it with your own domain name and mailing info:
<%
DIM Mailer, strEmail, strMsgHeader, qryItem, strMsgInfo
DIM strYourEmail, strYourName, strRecipEmail, strRecipName
DIM strComments, strURL, Mail
strYourEmail = Request.Form("YourEmail")
strYourName = Request.Form("YourName")
strRecipEmail = Request.Form("RecipEmail")
strRecipName = Request.Form("RecipName")
strComments = Request.Form("Comments")
strURL = Request.Form("URL")
Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.FromAddress = strYourEmail
Mailer.ReplyTo = strYourEmail
Mailer.RemoteHost = "YOUR_DOMAIN_NAME.COM"
Mailer.AddRecipient strRecipName, strRecipEmail
Mailer.Subject = "Look at this page from the YOUR_WEBSITE_NAME_HERE website"
strMsgHeader = "This mail message was sent from the YOUR_DOMAIN_NAME_HERE website" & vbCrLf & vbCrLf
Mailer.BodyText = strMsgHeader & vbCrLf & strRecipName & "," & vbCrLf & vbCrLf & strYourName & " wants you to take a look at this page at YOUR_WEBSITE_NAME_HERE:" & vbCrLf & "Page Link: " & strURL & vbCrLf & vbCrLf & strComments
IF Mailer.SendMail THEN
strYourName = request.form("YourName")
Response.Write strYourName
%>
,</p>
<p>Thank you for sharing this page with
<%
strRecipName = request.form("RecipName")
Response.Write strRecipName
%>
. Your message has been sent successfully and will be received by
<%
strRecipName = request.form("RecipName")
Response.Write strRecipName
%>
shortly.</p>
<%
ELSE
Response.Write "Sorry, there was an error and your email could not be sent at this time."
END IF
%>
That’s all there is to it. The confirmation page is customized so that it displays the names of the sender and recipient. Now, people can email and share your web pages.