Wednesday, 30 November 2011

EMAIL THIS PAGE

Another simple and very valuable tool to add to your website is the Email This Page tool. 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:


ASP Web Pro




Email This Page




Next, create a page in your root directory called emailthispage.asp and paste the following code:


ASP Web Pro




<%
DIM strURL
strURL = Request.ServerVariables("HTTP_Referer")

IF strURL = "" THEN
Response.Write "Sorry, your browser does not support this function."
END IF
%>

Page Link: <%= strURL %>













Your Email:
Your First Name:
Recipient's Email:
Recipient's First Name:


Comments:







Last, create a confirmation page called emailthispageconfirm.asp, paste the following code, and customize it with your own domain name and mailing info:


ASP Web Pro




<%
DIM Mailer, strEmail, strMsgHeader, qryItem, strMsgInfo
DIM strYourEmail, strYourName, strRecipEmail, strRecipName, 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
%>
,

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.

<%
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 even customized so that it displays the sender's and recipient's names. Now, anytime one of your website users sees something interesting, they can email that page link to any email address they want. In essence, it helps drive more traffic to your website!

http://www.aspwebpro.com/aspscripts/websitetools/emailthispage.asp

No comments:

Post a Comment