<% @Language = "VbScript"%> <% Option Explicit Response.Buffer = true Dim Title, LastName, FirstName, Email, Subject, ebody, SentOk, Msg, SentMsg, Referer, b, ThisPage, FormName, i, S1, S2 ' ' --------- Configure Appearence------- Const Txt1= "Eurosol    " ' Line 1 heading text Const Txt2 = "" ' Line 2 heading text Const BackgroundMain = "#1F5F7F" ' Background color - Overall page Const BackgroundBox = "#4F8FFF" ' Background color - Contrasting 'email entry panel' Const ForegroundBox = "#000000" ' Foreground color - Contrasting text box captions. Const ExtCss = "" ' Optional external CSS style sheet, eg "./style1.css" ' --------- Configure Hard code ------- Const ReturnPage = "index.htm" ' if user cancels and no referer, page to redirect to Const CKey = "E06" ' your domain identifier key to retreive certain cookies Const Prefix = "[E06] " ' Optional Subject prefix, eg "[A01] " Const ToList = "formsbp@eurosol.com,ken@eurosol.com"' To: (single or multiple Csv "me@you.com,you@me.com" ' ------------------------------------- ' ' Const SpamMsg = "Phrases containing '/', '#' or 'href' are not allowed" ' ' ----- Get this page's name ---- SetNames ThisPage, FormName ' Now we won't have to re-code if we rename this page. ' ' --- Identify refererer page --- Referer = Request("Referer") ' Check for any new referer page querystring If Len(Referer) = 0 Then ' If there isn't a querystring referer, Referer = Session("Referer") ' the check for a session var referer. If Len(Referer) = 0 Then ' If no session var referer then assign Referer = ReturnPage ' the page we defined in configuration section Session("Referer") = Referer ' and write the session var. End If ' otherwise we now have the referer in session var. Else ' If new incoming querystring referer Session("Referer") = Referer ' write it to the referer session var. End If ' ' --- Test if cookies enabled --- If Session("CTest") = "" then ' If no ASP session var has been written by this page yet Session("CTest") = "T" ' then set the session var to anything, say "T" (for test) Response.cookies("CTest") = FormName ' create a test cookie and assign it the form name. Response.Cookies(CKey).Expires = (now() + 1) ' Persist/store the value for one day. Response.redirect ThisPage ' redirect back to this page. ElseIf Request.cookies("CTest") = formName Then ' If session var exists, we have done the redirect, read the Session("CTest") = "Y" ' test cookie, if its the form name we saved, then set Else ' the session var to 'Y' (cookies are enabled), otherwise Session("CTest") = "N" ' set the session var to 'N' (cookies NOT enabled) End If ' ' --- Service form submission --- SentOk = False ' Initialize the success flag. If Request.Querystring("s") = "y" Then ' If page was 'submitted', then get Title = Request.Form("Title") ' all the values that were submitted. FirstName = Request.Form("FirstName") LastName = Request.Form("LastName") Email = Request.Form("Email") Subject = Request.Form("Subject") ebody = Request.Form("ebody") ' ' --- Test for Spam injection, save data, format and Send --- If SpamFree then ' Test for spam. If SpamFree then If Session("CTest") = "Y" then WriteCookies ' If cookies are enabled Save data to cookies. ebody = FormatBody ' Format body data If LocalHost Then ' If we are in the local development SentOk = True ' environment flag as sent, SentMsg = "Pretend sent to " & ToList ' and issue a local msg. Else ' else we will 'send for real'. b = Split(ToList, ",") ' Get target email address/es For i = LBound(b) to Ubound(b) ' Loop thro target email addresses If Len(Msg) = 0 Then ' If no errors so far then send SendMail b(i) ' the Email to next addr in ToList End If Next If Len(Msg) = 0 Then ' If no errors after 'Send' operation/s SentOk = True ' set the Ok flag to True, define 'Sent' msg. SentMsg = "Thank you - your email was sent." End If End If Else ' If there was spam, create CreateUserMsg SpamMsg ' the user rejection msg. end if Else ' If form was loaded, 'not submtted', ReadCookies ' attempt to get last entered user values End if ' from cookies If Title = "Mr" then S1 = " CHECKED" ' Set appropriate radio button If Title = "Ms" then S2 = " CHECKED" ' if we have a valid Title %> Email Us <% If Len(ExtCss) > 0 Then %> <% End If%>
<%=Txt1%>
<%=Txt2%> Contact us here
If you have cookies enabled, your browser will remember this email when you next return to this page. <% If Not SentOk Then %>
<%=Msg%>
Gender > Mr (male)   > Ms (female)  
First name  
Last name  
  Email addr  
Subject  
Message




<% else%>





<%=SentMsg%>



We will reply to you as soon as possible




<% End If %>
<% Sub SetNames(ThisPage, FormName) ThisPage = Trim(LCase(Request.servervariables("SCRIPT_NAME"))) Do ' Remove any path chars in front of name, eg, './' If Left(ThisPage, 1) = "/" Or Left(ThisPage, 1) = "." Then ThisPage = Mid(ThisPage, 2) Else Exit Do End if Loop ' Remove any chars after name, eg, querystring If Instr(ThisPage, "?") > 0 Then ThisPage = Left(ThisPage, Instr(ThisPage, "?") - 1) FormName = Left(ThisPage, Instr(ThisPage, ".") - 1) ' Remove extension to use as form name End Sub Sub CreateUserMsg(M) ' Check we have new msg, format to taste If Len(msg) = 0 and Len(m) > 0 Then ' but don't overwrite any existing msg. msg=" " & m & " " End If End Sub Sub SendMail(ToList) ''Dim mailObj ''On Error Resume Next ''Set mailObj = Server.CreateObject("CDONTS.NewMail") ''mailObj.BodyFormat = 0 ''mailObj.MailFormat = 0 ''mailObj.From = "(" & Trim(FirstName & " " & LastName) & ") " & Email ''mailObj.To = ToList ''mailObj.Subject = Prefix & Subject ''mailObj.Body = ebody ''mailObj.Send ''Set mailObj = Nothing ''If err.number <> 0 Then Msg = "Sorry. Error: " & err.description %> <% dim cdoConfig, cdoMessage Set cdoConfig = CreateObject("CDO.Configuration") With cdoConfig.Fields .Item(cdoSendUsingMethod) = cdoSendUsingPort .Item(cdoSMTPServer) = "mail.eurosol.com" .Item(cdoSMTPAuthenticate) = 1 .Item(cdoSendUsername) = "ken@eurosol.com" .Item(cdoSendPassword) = "081242" .Update End With Set cdoMessage = CreateObject("CDO.Message") With cdoMessage Set .Configuration = cdoConfig .From = "(" & Trim(FirstName & " " & LastName) & ") " & Email .To = ToList .Subject = Prefix & Subject .TextBody = ebody .Send End With If err.number <> 0 Then Msg = "Sorry. Error: " & err.description Set cdoMessage = Nothing Set cdoConfig = Nothing End Sub Sub WriteCookies ' Write cookies using the private Key Response.cookies(CKey)("Firstname") = Firstname Response.cookies(CKey)("LastName") = LastName Response.cookies(CKey)("Title") = Title Response.cookies(CKey)("Email") = email Response.cookies(CKey)("Subject") = Subject Response.cookies(CKey)("ebody") = ebody Response.Cookies(CKey).Expires = (now() + 5000) ' persist cookie for 5000 days End Sub Sub ReadCookies ' Read cookies using the private Key Title = Request.Cookies(CKey)("Title") firstname = Request.Cookies(CKey)("firstname") LastName = Request.Cookies(CKey)("Lastname") email = Request.Cookies(CKey)("email") Subject = Request.Cookies(CKey)("Subject") ebody = Request.Cookies(CKey)("ebody") End Sub Function SpamFree() ' We test for bad chars again in Dim b ' case JavaScript was turned off SpamFree = False ' Default return value to False b = FirstName & LastName & Email & Subject & ebody ' Concatenate input, scan for bad If Instr(b, "/") <> 0 Then Exit Function ' chars like '/' used in paths If Instr(b,"#") <> 0 then Exit Function ' or '#' used to dummy like #124; If Instr(1, b, "href", 1) <> 0 then Exit Function ' or 'href' used for links. SpamFree = True ' If no bad chars, return True End Function Function FormatBody() ' Make email appearence good in all email clients. FormatBody = "Title: " & Title & vbcrlf & "
" FormatBody = FormatBody & "FirstName: " & FirstName & vbcrlf & "
" FormatBody = FormatBody & "LastName: " & LastName & vbcrlf & "
" FormatBody = FormatBody & "Email: " & Email & vbcrlf & "
" FormatBody = FormatBody & "Subject: " & Prefix & Subject & vbcrlf & "
" FormatBody = FormatBody & "Body: " & ebody & vbcrlf & "
" End Function Function LocalHost() dim h LocalHost = False h = Request.ServerVariables("HTTP_HOST") & "" If Len(h) > 4 Then If LCase(Left(h, 5)) = "local" Then LocalHost = True End Function %>