%@ LANGUAGE="VBSCRIPT" %>
<%
'Dim objCDONTS ' Email object
Dim Mailer ' new Email object
Dim strFromName, strToName ' From/To persons' real name
Dim strFromEmail, strToEmail ' Email addresses
Dim strSubject, strBody ' Message
Dim strComments ' Additonal Comments
Dim strStoryURL ' Stories URL
Dim strThisPage ' This page's URL
Dim strReferringPage ' The referring page's URL
Dim bValidInput ' A boolean indicating valid parameters
' Retrieve this page name and referring page name
strThisPage = Request.ServerVariables("SCRIPT_NAME")
strReferringPage = Request.ServerVariables("HTTP_REFERER")
' Debugging lines:
'Response.Write strThisPage & "
" & vbCrLf
'Response.Write strReferringPage & "
" & vbCrLf
' Read in and set the initial values of our message parameters
strFromName = Trim(Request.Form("txtFromName"))
strFromEmail = Trim(Request.Form("txtFromEmail"))
strToName = Trim(Request.Form("txtToName"))
strToEmail = Trim(Request.Form("txtToEmail"))
strSubject = "Check out this story from adventure.mountainzone.com"
strBody = Trim(Request.Form("txtMessage"))
' strStoryURl is either the strReferringPage the first time or it's taken from the input
if InStr(1, strReferringPage, "/email/index.asp") > 1 then
strStoryURL = Trim(Request.Form("txtStoryURL"))
else
strStoryURL = strReferringPage
end if
strComments = Trim(Request.Form("txtComments"))
' I set the body message to a message that referenced the page the
' user arrived from. This makes it great if you place a link to it
' from your different articles, but can be weird if people link in
' from other web sites.
If strBody = "" Then
If strReferringPage = "" Or InStr(1, strReferringPage, "adventure.mountainzone.com", 1) = 0 Then
strBody = ""
strBody = strBody & vbCrLf
strBody = strBody & "Hey, " & strToName & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "I found this story on adventure.mountainzone.com..." & vbCrLf
strBody = strBody & "I thought you'd like to see it!" & vbCrLf
strBody = strBody & "=========================================" & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "Check it out at: " & vbCrLf
strBody = strBody & " " & strStoryURL & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "=========================================" & vbCrLf
strBody = strBody & "Comments" & vbCrLf
strBody = strBody & strComments & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "later, " & strFromName & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "=========================================" & vbCrLf
strBody = strBody & "For MORE adventure.mountainzone.com stories, checkout: " & vbCrLf
strBody = strBody & "ECO-CHALLENGE 2000........ http://www.ecochallenge2000.com " & vbCrLf
strBody = strBody & "NEWS........ http://adventure.mountainzone.com/2000/news/html/ " & vbCrLf
strBody = strBody & "HI-TEC...... http://adventure.mountainzone.com/2000/hitec/html/ " & vbCrLf
strBody = strBody & "XTERRA..... http://adventure.mountainzone.com/2000/xterra/html/ " & vbCrLf
strBody = strBody & "=========================================" & vbCrLf
Else
strBody = ""
strBody = strBody & vbCrLf
strBody = strBody & "Hey, " & strToName & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "I found this story on adventure.mountainzone.com..." & vbCrLf
strBody = strBody & "I thought you'd like to see it!" & vbCrLf
strBody = strBody & "=========================================" & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "Check it out at: " & vbCrLf
strBody = strBody & " " & strStoryURL & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "=========================================" & vbCrLf
strBody = strBody & "Comments" & vbCrLf
strBody = strBody & strComments & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "later, " & strFromName & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "=========================================" & vbCrLf
strBody = strBody & "For MORE adventure.mountainzone.com stories, checkout: " & vbCrLf
strBody = strBody & "ECO-CHALLENGE 2000........ http://www.ecochallenge2000.com " & vbCrLf
strBody = strBody & "NEWS........ http://adventure.mountainzone.com/2000/news/html/ " & vbCrLf
strBody = strBody & "HI-TEC...... http://adventure.mountainzone.com/2000/hitec/html/ " & vbCrLf
strBody = strBody & "XTERRA..... http://adventure.mountainzone.com/2000/xterra/html/ " & vbCrLf
strBody = strBody & "=========================================" & vbCrLf
End If
End If
' Quick validation just to make sure our parameters are somewhat valid
bValidInput = True
bValidInput = bValidInput And strFromName <> ""
bValidInput = bValidInput And IsValidEmail(strFromEmail)
bValidInput = bValidInput And IsValidEmail(strToEmail)
' If valid send email and show thanks, o/w show form
If bValidInput Then
' Set up our email object and send the message
strBody = strBody & "From your friends at http://adventure.mountainzone.com"
Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.FromName = strFromName
Mailer.FromAddress = strFromEmail
Mailer.RemoteHost = "smtp.tzn.com"
'Mailer.AddRecipient "slave to fashion", "james.dailey@quokka.com"
Mailer.AddRecipient strToName, strToEmail
Mailer.Subject = strSubject
Mailer.BodyText = strBody
Mailer.Priority = 1
Mailer.Urgent = true
if Mailer.SendMail then
ShowThanksMsg
else
Response.Write "Mail failure.
"
Response.Write Mailer.Response
end if
'old email functionality uses CDONTS dll
'Set objCDONTS = Server.CreateObject("CDONTS.NewMail")
' objCDONTS.From = strFromName & " <" & strFromEmail & ">"
' objCDONTS.To = strToEmail
' objCDONTS.Subject = strSubject
' objCDONTS.Body = strBody
' objCDONTS.Send
' Set objCDONTS = Nothing
' Show our thank you message
'ShowThanksMsg
Else
'If "http://" & Request.ServerVariables("HTTP_REFERER") = strStoryURL Then
If "http://" & Request.ServerVariables("HTTP_HOST") & strThisPage = strReferringPage Then
Response.Write "There's been an ERROR... you've missed a field.
" & vbCrLf
Response.Write "Please hit your browser's Back Button to reset URL & check your entries:" & "
" & vbCrLf
End If
' Show our information retrieval form
ShowReferralForm strFromName, strFromEmail, strToName, strToEmail, strStoryURL, strBody
End If
' End of page logic... subs and functions follow!
%>
<%
' Subroutines and Functions that encapsulate some functionality
' and make the above code easier to write... and read.
' A quick email syntax checker. It's not perfect,
' but it's quick and easy and will catch most of
' the bad addresses than people type in.
Function IsValidEmail(strEmail)
Dim bIsValid
bIsValid = True
If Len(strEmail) < 5 Then
bIsValid = False
Else
If Instr(1, strEmail, " ") <> 0 Then
bIsValid = False
Else
If InStr(1, strEmail, "@", 1) < 2 Then
bIsValid = False
Else
If InStrRev(strEmail, ".") < InStr(1, strEmail, "@", 1) + 2 Then
bIsValid = False
End If
End If
End If
End If
IsValidEmail = bIsValid
End Function
' I made this a function just to get it out of the
' logic and make it easier to read. It just shows the
' form that asks for the input
Sub ShowReferralForm(strFromName, strFromEmail, strToName, strToEmail, strStoryURL, strBody)
' I use script_name so users can rename this script witout having to change the code.
%>
<% strFromName = Request.Cookies ("txtFromName") %>
<% strFromEmail = Request.Cookies ("txtFromEmail") %>
adventure.mountainzone.com.com -- Email a Friend
 |

 adventure.mountainzone.com
 |
|
 |
Get your friends in on the action. Fill in the form below and we'll send the URL of this story to the address you specify. And rest assured, we respect your privacy - neither your address nor that of the recipient will be recorded - see our privacy policy.
|
Fill in ALL fields
|
|
|
|
RETURN TO STORY
© 1997-2000 Quokka
Sports, Inc. All rights reserved. Do not duplicate or redistribute in any
form.
|
|
|
<%
'The Message to be sent:
'Subject: < %= strSubject % >
'Body: < %= strBody % >
End Sub
' This just shows our thank you message... probably didn't need to
' be a function, but since I made the form one I figured I'd do this
' for consistency.
Sub ShowThanksMsg()
%>
adventure.mountainzone.com -- Email a Friend
 |

 adventure.mountainzone.com
 |
|
 |
<%= strFromName %>, Thanks for sending this story to your friend:
|
|
|
Your message has been successfully sent. Thanks for helping us spread the word about the great stories we have on adventure.mountainzone.com!
Your message has been sent to:
<%= strToName %>
<%= strToEmail %>
Your message was sent from:
<%= strFromName %>
<%= strFromEmail %>
|
|
|
RETURN TO STORY
© 1997-2000 Quokka
Sports, Inc. All rights reserved. Do not duplicate or redistribute in any
form.
|
|
|
<%
End Sub
%>