CodeAve.com CodeAve.com - ASP - Miscellaneous
ASP
·Read/Write
·Script Writers
·Database Display
·Response Objects
·Server Variables
·Random Events
·Articles
·Miscellaneous
·Contents
·What's New?
JavaScript
CSS
HTML
Maps
Links
Mail List
Search
Sitemap


 


Mail A Link
Enabling people to mail the link of the current page is an incredibly useful feature to incorporate into your site. People can easily share items viewed with others and mail items without the need for an internet capable email account and bring users back to your site for a second view. There are many ways that this can be accomplished. The following is probably one of the easiest to incorporate. On each page you will need to provide a link or input button that will link to the mail application. When clicked, the referring page url will always be available to display as request.servervariables(“http_referer”). However, mailing a link without knowing much about its contents does not do much. So, by utilizing some simple JavaScript the title of the page can easily be passed and incorporated into the email message. This example demonstrates the use of CDONTS for mailing your info, but has been commented out to prevent overuse and abuse of the CodeAve.com mail server. You may also want to include a note on you page detailing that mail addresses are not collected to let people feel secure that their info is not being gathered in your application.
View the Output
Text View
Print View
Mail this Link
Download the Code

mailalink.htm
<html>
<title>Mail A Link Example</title>
<body bgcolor="#FFFFFF">
<!-- Either of the following should be placed on the page(s)
you like to have the mail a link featured on -->
<form action="mailalink.asp" method="post">
Mail A Link Form Example<br>
<script language=JavaScript>
var title = "<input type='hidden' name='title' value='" + document.title + "'>"
document.write (title)
</script>
<input type="submit" value="Mail This Link">
</form>

<p>&nbsp;</p>

Mail A Link Hyperlink Example<br>
<script language=JavaScript>
var title = "<a href='mailalink.asp?title=" + document.title + "'>Mail This Link</a>"
document.write (title)
</script>

</body>
</html>

mailalink.asp
<html>
<body bgcolor="#FFFFFF">
<title>Mail-A-Link</title>
<% ' Grab the title and referring page
title=trim(request.querystring("title"))
referer=request.servervariables("http_referer")
if title = "" then 
title=trim(request.form("title"))
end if
u_submitted=trim(request.form("u_submitted"))
' u_submitted checks to see if the form with an email address was submitted
if referer = "" then
' If there is no referring page display an appropriate message
response.write "You have reached the Mail-A-Link page, but we were unable to recognize the previous page"
response.end
end if ' End check for referer
' If the form with the email address has benn submittes send the mail
if u_submitted <> "Yes" then
%>

<form action="<%= request.servervariables("script_name") %>" method="post">
<b>Subject:</b> <%= title %>
<br>
<b>Link:</b> <%= referer %>
<p>
Enter the email address of the recipient<br>
<input type="text" name="u_email">
<input type="hidden" name="title" value="<%= title %>">
<input type="hidden" name="referer" value="<%= referer %>">
<input type="hidden" name="u_submitted" value="Yes">
<input type="submit" value="Sumbit">

<% else
referer=request.form("referer") 
body = "The following link was sent to you by a user of YourServer.com" 
body = body & "Subject:" & title 
body = body & "Link:" & referer

' This is the begining of the email creation and execution
' Remove the comments befor each statement that begins with Set or sm
' to actually send the mail message

' Create a new mail object on the server
' set sm = server.CreateObject("CDONTS.Newmail") 

' Declare what address is sending the message
' sm.from = "requested_link@yourserver.com" 

' Write the users subject to the subject of the email
' sm.Subject = "Requested Link:" & title

' Declare what address the message is being sent to
' The Addressee is set to the inputted value
' sm.to = u_email

' Write the users message to the body of the email
' sm.body = u_body 

' Send the message
' sm.Send 

' Clean up the server object
' set sm = nothing 
%>

Your mail has been sent
<% end if 'end check for submission with an email address %>
</body>
</html>

 

 

 



ASP: What's New? | Articles | Script Writers | Database Display | Read/Write
Server Variables | Response Objects | Random Events | Miscellaneous
HTML: Forms | Hyperlinks | Headers | Tables | Hyperlinks | Headers | Text Display
JavaScript: Document Info | Forms | Images | Navigation | Script Writers
CSS: Basics | Page Display | Text Display | Script Writers | Miscellaneous
  • 2014 michael kors
  • air max women 2013
  • 2014 michael kors
  • air max 2014
  • oakley glasses
  • oakley glasses

  • Maps: Map Script Writers | Bing Maps | Google Maps
  • bottes fr
  • ugg boot
  • Privacy Statement

    CodeAve.com is hosted by MyHosting.com
    Donate Food Online with a Mouse Click at TheHungerSite.com
    Donate Land Online with a Mouse Click at TheRainForestSite.com
    © 1999 - 2017 CodeAve.com
    All Rights Reserved

  • Kids jordan 6 rings
  • Jordan retro 10
  • Jordan retro 3