%
CardBuilderStep=0
ErrorFlag=False
FatalError=False
PasswordProvided=False
Function ValidStr(string)
for a=1 to len(string)
b=mid(string,a,1)
if b="'" then b="''"
c=c+b
next
ValidStr=c
End Function
' Get values from request
Password=Request.QueryString("Password")
' Check whether password has been provided by user.
IF IsNull(Password) Then
PasswordProvided=False
Else
If trim(Password)<>"" Then
PasswordProvided=True
End If
End If
' Make connection to Postcard Database
Set ODBCConnection = Server.CreateObject("ADODB.Connection")
ODBCConnection.Open "FinlaystoneAdmin"
If Request.Form("Callback")="Send" Then
PostcardID=Request.Form("PostcardID")
FromName=Request.Form("FromName")
FromEmail=Request.Form("FromEmail")
ToName=Request.Form("ToName")
ToEmail=Request.Form("ToEmail")
MessageText=Request.Form("MessageText")
If IsNull(PostcardID) or IsNull(FromName) or IsNull(FromEmail) or IsNull(ToName) or IsNull(ToEmail) or IsNull(MessageText) then
FatalError=True
Else
PostCardID=int(PostCardID)
If PostCardID<1 Then ErrorFlag=True
If Trim(FromName)="" Then ErrorFlag=True : ErrorMessage=ErrorMessage+"From Name Required
"
If Trim(FromEmail)="" Then ErrorFlag=True : ErrorMessage=ErrorMessage+"From Email Required
"
If Trim(ToName)="" Then ErrorFlag=True : ErrorMessage=ErrorMessage+"Recipient Name Required
"
If Trim(ToEmail)="" Then ErrorFlag=True : ErrorMessage=ErrorMessage+"Recipient Email Required
"
If Trim(MessageText)="" Then ErrorFlag=True : ErrorMessage=ErrorMessage+"Message Text Required
"
End If
If ErrorFlag=True Then
If PostCardID<1 Then
CardBuilderStep=1
Else
CardBuilderStep=2
End If
Else
If Not FatalError Then
Password=""
PasswordAlreadyExists=True
While PasswordAlreadyExists
Randomize
Password=""
for a=1 to 10
Password=Password+Chr(Int(25*Rnd()) + 65)
Next
Set CheckForExistingPassword=ODBCConnection.Execute("SELECT MessageID FROM Postcard_Messages WHERE Password='"+Password+"';")
If not CheckForExistingPassword.Eof Then PasswordAlreadyExists=True Else PasswordAlreadyExists=False
CheckForExistingPassword.Close
Set CheckForExistingPassword=Nothing
Wend
MessageCreationDate=cDate(FormatDateTime(now(),2))
MessageExpiryDate=DateAdd("m",1,MessageCreationDate)
SaveMessageSQL="INSERT INTO Postcard_Messages(PostCardID,Password,MessageCreationDate,MessageExpiryDate,FromName,FromEmail,ToName,ToEmail,MessageText) VALUES ("
SaveMessageSQL=SaveMessageSQL+trim(cstr(PostCardID))+","
SaveMessageSQL=SaveMessageSQL+"'"+ucase(trim(Password))+"',"
SaveMessageSQL=SaveMessageSQL+"#"+trim(formatdatetime(MessageCreationDate,1))+"#,"
SaveMessageSQL=SaveMessageSQL+"#"+trim(formatdatetime(MessageExpiryDate,1))+"#,"
SaveMessageSQL=SaveMessageSQL+"'"+trim(validstr(FromName))+"',"
SaveMessageSQL=SaveMessageSQL+"'"+trim(validstr(FromEmail))+"',"
SaveMessageSQL=SaveMessageSQL+"'"+trim(validstr(ToName))+"',"
SaveMessageSQL=SaveMessageSQL+"'"+trim(validstr(ToEmail))+"',"
SaveMessageSQL=SaveMessageSQL+"'"+trim(validstr(MessageText))+"')"
ODBCConnection.Execute(SaveMessageSQL)
Set JMail = CreateObject("JMail.SMTPMAIL")
CRLF=Chr(13)+chr(10)
EMAIL_TO = trim(ToName)
EMAIL_MESSAGE = "You have been sent a postcard by " +trim(FromName)+ " (" + trim(FromEmail)+ ")."+chr(13)+chr(10)+chr(13)+chr(10)
EMAIL_MESSAGE = EMAIL_MESSAGE + "Please point your Web browser to http://www.finlaystone.co.uk/viewpostcard.asp?password=" +trim(Password)+chr(13)+chr(10)
EMAIL_MESSAGE = EMAIL_MESSAGE + "Alternatively, point your browser to go to http://www.finlaystone.co.uk/viewpostcard.asp and key in the password " + trim(Password) + "."+chr(13)+chr(10)+chr(13)+chr(10)
EMAIL_MESSAGE = EMAIL_MESSAGE + "Your postcard will expire on " + trim(formatdatetime(MessageExpiryDate,1)) + "."+chr(13)+chr(10)
EMAIL_MESSAGE = EMAIL_MESSAGE + "With the compliments of Finlaystone Estate."
JMail.ServerAddress = "mail.marcat.com"
JMail.SenderName="Finlaystone Estate"
JMail.Sender = "ranger@finlaystone.co.uk"
JMail.Subject = "You have a Postcard!"
JMail.AddRecipient(cstr(trim(ToEmail)))
JMail.Priority = 1
JMail.Body = EMAIL_MESSAGE
JMail.Execute
End If
End If
Else
If Request.QueryString("PostCardID")<>"" Then
PostCardID=trim(Request.QueryString("PostCardID"))
CardBuilderStep=2
Else
CardBuilderStep=1
PostCardID=""
End IF
If PasswordProvided Then
SQLStatement="SELECT * FROM Postcard_Messages WHERE Password='"+Password+"';"
Set Messages=ODBCConnection.Execute(SQLStatement)
If not Messages.EOF Then
FromName=Messages("ToName")
FromEmail=Messages("ToEmail")
ToName=Messages("FromName")
ToEmail=Messages("FromEmail")
End If
Messages.Close
Set Messages=Nothing
End If
End If
If CardBuilderStep=2 Then
' Get the Image Name for displaying the card in the second step of the Card Builder.
SQLStatement="SELECT PostcardImageName_Fullsize FROM Postcard_Postcards WHERE PostcardID="+trim(cstr(PostcardID))+";"
Set GetImageName=ODBCConnection.Execute(SQLStatement)
If Not GetImageName.EOF Then
PostCardImageName_Fullsize=GetImageName("PostcardImageName_Fullsize")
Else
' Fail back to CardBuilder step 1 if problems encountered with database.
CardBuilderStep=1
End If
GetImageName.Close
Set GetImageName=Nothing
End If
If CardBuilderStep=1 Then
' Load all the card information into an array for CardBuilder Step 1
PostcardSQL="SELECT * FROM Postcard_Postcards ORDER BY PostcardName;"
Set Postcard=ODBCConnection.Execute(PostcardSQL)
PostcardCounter=0
Dim PostcardIDs(50)
Dim PostcardNames(50)
Dim PostcardImageName_Thumbs(50)
Dim PostcardImageName_Fullsize(50)
If not Postcard.EOF Then
While not Postcard.EOF
PostcardCounter=PostcardCounter+1
PostcardIDs(PostcardCounter)=Postcard("PostcardID")
PostcardNames(PostcardCounter)=Postcard("PostcardName")
PostcardImageName_Thumbs(PostcardCounter)=Postcard("PostcardImageName_Thumb")
PostcardImageName_Fullsize(PostcardCounter)=Postcard("PostcardImageName_Fullsize")
Postcard.Movenext
Wend
Else
FatalError=True
End If
If Not FatalError then CardBuilder=True
Postcard.Close
Set Postcard=Nothing
Else
If Not ErrorFlag and Not FatalError Then
End If
End If
ODBCConnection.Close
Set ODBCConnection=Nothing
'Next comes the HTML header information..
%>
![]() |
![]() |
![]() ![]() |
|
|
Click here to return home. " Else Response.Write "Your postcard has been sent to "+trim(toemail)+"... Click here to send another postcard. | |||||||||||||||||
Home | Contact Us | News & Events | Admission & Find Us Children & Schools | Gardens | Woodlands | Giftshop & Tearoom | About the Rangers | History | Architecture Finlaystone Country Estate, Langbank, Renfrewshire, PA14 6TJ, Scotland Tel./Fax +44 (0)1475-540505 |