<%@ Language=VBScript %> <% ' --- query string processing for error codes ' --- declare variables Dim strErrText, strCode strErrText = "" strCode = Request.QueryString("code") ' --- check the querystring for code=value parameters and show the error Select Case strCode Case "1" strErrText = "Please press the Back button to enter information in all required fields." Case "2" strErrText = "Please press the Back button to enter a valid email address." End Select ' --- CDOSYS email processing ' --- make sure the PickUp folder in Exchange has NTFS write ' --- permissions for the respective application pool identity, ' --- default is NETWORK SERVICE If Request.ServerVariables("REQUEST_METHOD") = "POST" Then Dim strFormManager, strName, strOrganization, strPhone, strEmail, strSubject, strText, strBody strFormManager = "info@thewadegroupinc.com" ' --- change this email to desired FormManager email ' --- retrieve user input from the web form strName = Trim(Request.Form("cName")) strOrganization = Trim(Request.Form("cOrganization")) strPhone = Trim(Request.Form("cPhone")) strEmail = Trim(Request.Form("cEmail")) strSubject = Trim(Request.Form("cSubject")) strText = Trim(Request.Form("cText")) 'optGender = Request.Form("gender").Item ' --- check required fields for empty values If strName = "" Or strOrganization = "" Or strPhone = "" Or strEmail = "" Or strSubject = "" Or strText = "" Then Response.Redirect "contactform.asp?code=1" End If If isValidEmail(strEmail) <> true Then Response.Redirect "contactform.asp?code=2" End If ' --- begin email prep Dim oMail Set oMail = CreateObject("CDO.Message") ' --- build email from the web form fields oMail.Subject = "Contact Form: " & strSubject oMail.From = "\TheWadeGroup" & Chr(130) & " Inc" & Chr(46) & "\ " ' oMail.Configuration.Fields.Item("urn:schemas:httpmail:importance").Value = 2 'set [2=high,1=normal,0=low] ' oMail.Configuration.Fields.Item("urn:schemas:mailheader:priority") = 1 'set [1, 0 , -1] ' oMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 ' oMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.server.com" 'name or IP of remote SMTP server ' oMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 'server port oMail.Configuration.Fields.Update strBody = "This e-mail was generated on " & FormatDateTime(Now(), 0)_ & " as a result of a submission from host [" & Request.ServerVariables("REMOTE_ADDR")_ & "] via the Contact Form at TheWadeGroup, Inc. website http://www.thewadegroupinc.com with the following information:"_ & VBCrLf & VBCrLf strBody = strBody & "Name: " & strName & VBCrLf strBody = strBody & "Organization: " & strOrganization & VBCrLf strBody = strBody & "Phone: " & strPhone & VBCrLf strBody = strBody & "E-mail: " & strEmail & VBCrLf strBody = strBody & "Subject: " & strSubject & VBCrLf strBody = strBody & VBCrLf & "************************************" & VBCrLf & VBCrLf strBody = strBody & strText & VBCrLf & VBCrLf & "************************************" & VBCrLf & VBCrLf ' --- verify the Copy checkbox and finalize building email If Request.Form("chkCopySelf") = "on" Then oMail.To = strEmail oMail.Cc = "" oMail.Bcc = strFormManager strBody = strBody & "This carbon copy was requested by the author and is not SPAM. It is provided as a courtesy to our valued website visitors. Please delete this message and accept our sincere apologies if you received it in error." & VBCrLf & "Copyright © 2008 TheWadeGroup, Inc." oMail.TextBody = strBody End If If Request.Form("chkCopySelf") <> "on" Then oMail.To = strFormManager oMail.Cc = "" oMail.Bcc = "" oMail.TextBody = strBody End If ' --- send email oMail.Send ' --- clean up Set oMail = Nothing Set strFormManager = Nothing Set strName = Nothing Set strOrganization = Nothing Set strPhone = Nothing Set strEmail = Nothing Set strSubject = Nothing Set strText = Nothing ' --- execute confirmation Response.Redirect "confirm.html" End If ' --- email validator Function isValidEmail(myEmail) ' --- my old regular expression for email validation "\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" Dim regEx, isValidE isValidE = true Set regEx = New RegExp regEx.IgnoreCase = False regEx.Pattern = "^[a-zA-Z0-9]*[\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 %>

Contact Form

<% =strErrText %>

Name: Organization: Phone: E-mail: Subject: Text:
  Send me a copy