%
Const TESTING = False
' iif(expr1, expr2, expr3)
' Replaces missing Immediate IF in VB Script. If is TRUE, iif() returns
' otherwise is returned.
Function iif(expr1, expr2, expr3)
If expr1 Then
iif = expr2
Else
iif = expr3
End If
End Function
' isValidEmail(myEmail)
' Returns TRUE if the email address passed is valid. Uses vb regular expression object to ensure
' accuracy - email address must meet accepted grammar to be valid.
Function isValidEmail(myEmail)
dim isValidE
dim regEx
isValidE = True
set regEx = New RegExp
regEx.IgnoreCase = False
regEx.Pattern = "^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"
isValidE = regEx.Test(myEmail)
isValidEmail = isValidE
End Function
' For documentation, vars declared seperately, more efficient to leave out comments and declare on a single line
Dim Action 'self-calling page control
'Dim Subject 'message subject
Dim Who 'message recipient name (not email address)
Dim UserName
Dim errUserName
Dim Address 'address
Dim City 'city
Dim UserState 'state
Dim Zip 'zip
Dim Country
Dim DayPhone ' phone
Dim errDayPhone 'error text for invalid phone
Dim EvePhone 'evening phone number
Dim errEvePhone 'evening phone number
'Dim errSubject 'err text for missing subject
Dim EmailTo 'message recipient email address
Dim Mailer 'script object for instance of ASPEmail component
Dim EmailFrom 'message sender email address
Dim errFrom
Dim PrefDates 'thank you or other message to web visitor
Dim BodyText 'message text
Dim CharterType
Dim FishSpecies
Dim Tackle
Dim Health
Dim More
Dim NumAdults
Dim NumChildren
Dim HeardFrom
'Request Action from the calling page...
Action = Request("Action")
'check the Action variable...if it's value is "send" we know that this page
'has been called by itself, so begin collecting form variables from the http POST,
'set up the mailer com object, invoke the send message method, and check for errors.
'Finish up by giving the user a meaningful message.
If Action = "Send" Then
'collect form variables
Who = "Intrepid Sportfishing Website Contact Form"
UserName = Request.Form("Name")
Address = Request.Form("Address")
City = Request.Form("City")
UserState = Request.Form("State")
Zip = Request.Form("Zip")
Country = Request.Form("Country")
DayPhone = Request.Form("DayPhone")
EvePhone = Request.Form("EvePhone")
PrefDates = Request.Form("PrefDates")
CharterType = Request.Form("CharterType")
FishSpecies = Request.Form("FishSpecies")
Tackle = Request.Form("Tackle")
Health = Request.Form("Health")
More = Request.Form("More")
NumAdults = Request.Form("NumAdults")
NumChildren = Request.Form("NumChildren")
HeardFrom = Request.Form("HeardFrom")
EmailFrom = Trim(Request.Form("email"))
BodyText = "Name:" & " " & UserName & VbCrLf
BodyText = BodyText & "Address:" & " " & Address & VbCrLf
BodyText = BodyText & "City:" & " " & City & VbCrLf
BodyText = BodyText & "State:" & " " & UserState & VbCrLf
BodyText = BodyText & "Zip:" & " " & Zip & VbCrLf
BodyText = BodyText & "Country:" & " " & Country & VbCrLf
BodyText = BodyText & "Daytime Phone:" & " " & DayPhone & VbCrLf
BodyText = BodyText & "Evening Phone:" & " " & EvePhone & VbCrLf
BodyText = BodyText & "Email:" & " " & EmailFrom & VbCrLf & VbCrLf
BodyText = BodyText & "Preferred Dates:" & " " & PrefDates & VbCrLf & VbCrLf
BodyText = BodyText & "Type of Charter:" & " " & CharterType & VbCrLf & VbCrLf
BodyText = BodyText & "Species of Fish Preferred:" & " " & FishSpecies & VbCrLf & VbCrLf
BodyText = BodyText & "Tackle:" & " " & Tackle & VbCrLf & VbCrLf
BodyText = BodyText & "Health Concern or Physical Challenges:" & " " & Health & VbCrLf & VbCrLf
BodyText = BodyText & "Anything else?" & " " & More & VbCrLf & VbCrLf
BodyText = BodyText & "Number of adults:" & " " & NumAdults & VbCrLf
BodyText = BodyText & "Number and ages of children:" & " " & NumChildren & VbCrLf & VbCrLf
BodyText = BodyText & "How did you hear about the Intrepid?" & " " & HeardFrom & VbCrLf
'error checking...set error strings as appropriate
If UserName = "" Then
errUserName = " Please fill in your first and last name."
End if
If DayPhone = "" Then
errDayPhone = " Please fill in your daytime phone number."
End If
If EvePhone = "" Then
errEvePhone = " Please fill in your evening phone number."
End If
If not isValidEmail(EmailFrom) Then
errFrom = " Please fill in a valid email address."
End If
'concatenate all the error strings, if the result is blank, then we have no
'errors, otherwise, don't send the message, but rather display error message
If errUserName & errDayPhone & errEvePhone & errFrom = "" Then
Who = iif(TESTING,"debug",Who) 'use for debugging
'sort out the recipient from the droplist value
'Select Case Who
'Case "general" EmailTo = "info@wyomingnews.com"
'Case "sales" EmailTo = "sales@wyomingnews.com"
'Case "tech" EmailTo = "support@wyomingnews.com"
'End Select
EmailTo = "captdouginkona@yahoo.com"
'set up mailer object and send confirming emails
Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.RemoteHost = "mail.realbigfish.com;mail.lonetree.com"
Mailer.AddRecipient Who, EmailTo
'Mailer.AddRecipient "Webmaster", "jwoodard@wyomingnews.com"
Mailer.FromAddress = "captdouginkona@yahoo.com"
Mailer.ReplyTo = EmailFrom
Mailer.FromName = NameFrom
Mailer.Subject = "Intrepid Sportfishing Website Contact Form"
Mailer.BodyText = BodyText
'attempt to send the message; use SendMail method
If Mailer.SendMail Then
'good send, prepare a thank you message and set local vars to blank so
'that form displays with blank text boxes
msg = "Your message has been sent to Intrepid Sportfishing. We will contact you as soon as possible. "
'who = ""
'Message = ""
'Subject = ""
'EmailFrom = ""
'NameFrom = ""
Else
'error; prepare error message from objects error property
msg = "There was an error sending your message. Please scroll down to the form below. Error was " & Mailer.Response & " "
end If
Else
'some problem with one or more of the form variables...let user know...
msg = "There were some errors which prevented sending your message...please scroll down to the form below. "
End If
msg = " " & msg
else
msg = ""
End If
%>
<%=msg%>
Rates and Reservations
The Intrepid is a 42-foot LOA Bertram Yachtfisher
and is certified by the U.S. Coast Guard to carry six passengers.
She is very clean, well maintained and is in excellent condition. Boasting state-of-the-art electronics, she is
perfectly equipped for Hawaii sport fishing.
She is air-conditioned and has both bridge and salon seating which
can comfortably accommodate six adults. She is equipped with a toilet,
fresh water shower, two private staterooms, CD stereo, television and DVD player and is perfectly suited
for overnight trips as well as tournament fishing.
We have a custom aluminum boarding/dive ladder, allowing for safe and easy embarking and disembarking for snorkeling.
All trips include snacks and non-alcoholic beverages.