| Recommend This Page Using JMail |
To create this script (more like an application), we need the following:
In order for us to know what page the user is trying to recommend, we will put a link on that page that points to recommend.asp (the file used in this example). On recommend.asp, we use the following portion of the script:
<% Request.ServerVariables("HTTP_REFFERRER") %>
The Request.ServerVariables("HTTP_REFFERRER") only does one thing: It requests the URL of the page containing the link used to get to recommend.asp.
Let's get down to work now. First we set a link to the recommend.asp. Now let's take a look at the recommend.asp script.
| recommend.asp <% Dim link link = Request.ServerVariables("HTTP_REFFERRER") %> Please enter your e-mail address, your friend's e-mail address, name, plus subject and message in the text boxes below.<br><br> <form method="post" action="sendlink.asp"> Your Name: <input type=text name=email><br> Friend's e-mail: <input type="text" name="recipient"><br> <input type="text" name="subject"><br> <input type="textarea name="body" value="Here is an article I saw and thought you might be interested in it. There it is: <%=link%>."> <input type="Submit" value="Submit"> |
Now here is the code for sendlink.asp:
| : <% 'sendlink.asp Name = Request.Form("name") SenderEmail = Request.Form("email") Subject = "Regarding " & Request.Form("subject") Recipient = Request.Form("recipient") Body = Request.Form("body") Set JMail = Server.CreateObject("JMail.SMTPMail") Below you should enter your own SMTP-server JMail.ServerAddress = "xxx.zzz.yyy" JMail.Sender = Senderemail JMail.Subject = Subject JMail.AddRecipient Recipient JMail.Body = Body JMail.Priority = 3 JMail.AddHeader "Originating-IP", Request.ServerVariables("REMOTE_ADDR") JMail.Execute %> <center> <font face="Arial, geneva" size="3">The article recommended has been sent to <%= Recipient %> with your message.<br>Thank you very much. </font> </center> </body> </html> |