<%@ LANGUAGE="VBSCRIPT" %> <% option explicit %> <% Response.Buffer = True %> <% '*********************************************************************** ' Code Example : Self Submitting "Contact Us" Form Using CDOSYS '*********************************************************************** %> <% 'Declaring Variables Dim smtpserver,smtpEmail,smtpPassword,youremail,yourpassword,ContactUs_Name,ContactUs_Email,ContactUs_Phone,ContactUs_Street,ContactUs_CityStateZip Dim ContactUs_Subject,ContactUs_Body,Action,IsError ' Edit these 3 values accordingly smtpserver = "mail.simplesolutionsnc.com" smtpEmail = "mailto@simplesolutionsnc.com" smtpPassword = "23j6h2w2" youremail = Request("ContactUs_Recipiant") yourpassword = "" ' Grabbing variables from the form post ContactUs_Name = Request("ContactUs_Name") ContactUs_Email = Request("ContactUs_Email") ContactUs_Phone = Request("ContactUs_Phone") ContactUs_Subject = Request("ContactUs_Subject") ContactUs_Body = Request("ContactUs_Body") ContactUs_Street = Request("ContactUs_Street") ContactUs_CityStateZip = Request("ContactUs_CityStateZip") Action = Request("Action") ' Used to check that the email entered is in a valid format Function IsValidEmail(Email) Dim ValidFlag,BadFlag,atCount,atLoop,SpecialFlag,UserName,DomainName,atChr,tAry1 ValidFlag = False If (Email <> "") And (InStr(1, Email, "@") > 0) And (InStr(1, Email, ".") > 0) Then atCount = 0 SpecialFlag = False For atLoop = 1 To Len(Email) atChr = Mid(Email, atLoop, 1) If atChr = "@" Then atCount = atCount + 1 If (atChr >= Chr(32)) And (atChr <= Chr(44)) Then SpecialFlag = True If (atChr = Chr(47)) Or (atChr = Chr(96)) Or (atChr >= Chr(123)) Then SpecialFlag = True If (atChr >= Chr(58)) And (atChr <= Chr(63)) Then SpecialFlag = True If (atChr >= Chr(91)) And (atChr <= Chr(94)) Then SpecialFlag = True Next If (atCount = 1) And (SpecialFlag = False) Then BadFlag = False tAry1 = Split(Email, "@") UserName = tAry1(0) DomainName = tAry1(1) If (UserName = "") Or (DomainName = "") Then BadFlag = True If Mid(DomainName, 1, 1) = "." then BadFlag = True If Mid(DomainName, Len(DomainName), 1) = "." then BadFlag = True ValidFlag = True End If End If If BadFlag = True Then ValidFlag = False IsValidEmail = ValidFlag End Function If Action = "GetDirections" Then Dim strStreet, strCityStateZip, strRedirect strStreet = Replace(ContactUs_Street," ","+") strCityStateZip = Replace(ContactUs_CityStateZip," ","+") strRedirect = "http://maps.yahoo.com/dd_result?newaddr=" & strStreet & "&taddr=910+N+Sharon+Amity+Rd&csz=" & strCityStateZip & "&country=us&tcsz=Charlotte+NC+28211&tcountry=us" Response.Write "" End If If Action = "SendEmail" Then ' Here we quickly check/validate the information entered ' These checks could easily be improved to look for more things If IsValidEmail(ContactUs_Email) = "False" Then IsError = "Yes" %> <%End If If ContactUs_Name = "" Then IsError = "Yes" %> <%End If If ContactUs_Subject = "" Then IsError = "Yes" %> <%End If If ContactUs_Body = "" Then IsError = "Yes" %> <%End If End If ' If there were no input errors and the action of the form is "SendEMail" we send the email off If Action = "SendEmail" And IsError <> "Yes" Then ' Set Mail Recipiant If (youremail = "0") then youremail = "minnerlabrador@yahoo.com" End If If (youremail = "1") then youremail = "pastordbg@aol.com" End If If (youremail = "2") then youremail = "elliegreen@carolina.rr.com " End If If (youremail = "3") then youremail = "gregpflug@mac.com" End If If (youremail = "4") then youremail = "dawnbryantrnc@yahoo.com" End If If (youremail = "5") then youremail = "khorlane@yahoo.com" End If If (youremail = "6") then youremail = "john@simplesolutionsnc.com" End If Dim strBody ' Here we create a nice looking html body for the email strBody = strBody & "Contact Us Form submitted at " & Now() & vbCrLf & "

" strBody = strBody & "From http://" & Request.ServerVariables("HTTP_HOST") & vbCrLf & "
" strBody = strBody & "IP " & Request.ServerVariables("REMOTE_ADDR") & vbCrLf & "
" strBody = strBody & "Name" & " : " & " " & Replace(ContactUs_Name,vbCr,"
") & "
" strBody = strBody & "Email" & " : " & " " & Replace(ContactUs_Email,vbCr,"
") & "
" strBody = strBody & "Phone" & " : " & " " & Replace(ContactUs_Phone,vbCr,"
") & "
" strBody = strBody & "Subject" & " : " & " " & Replace(ContactUs_Subject,vbCr,"
") & "
" strBody = strBody & "
" & Replace(ContactUs_Body,vbCr,"
") & "
" strBody = strBody & "
" Dim ObjSendMail Set ObjSendMail = CreateObject("CDO.Message") 'This section provides the configuration information for the remote SMTP server. ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send the message using the network (SMTP over the network). ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = smtpserver ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False 'Use SSL for the connection (True or False) ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60 ' If your server requires outgoing authentication uncomment the lines bleow and use a valid email address and password. ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = smtpEmail ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = smtpPassword ObjSendMail.Configuration.Fields.Update 'End remote SMTP server configuration section== ObjSendMail.To = youremail ObjSendMail.Subject = ContactUs_Subject ObjSendMail.From = ContactUs_Email ' we are sending a html email.. simply switch the comments around to send a text email instead ObjSendMail.HTMLBody = strBody 'ObjSendMail.TextBody = strBody ObjSendMail.Send Set ObjSendMail = Nothing ' change the success messages below to say or do whatever you like ' you could do a response.redirect or offer a hyperlink somewhere.. etc etc Response.Write "" Response.Write "" Else %> Sharon Seventh-day Adventist Church
The Charlotte Sharon
Seventh-day Adventist Church
910 N Sharon Amity Rd
Charlotte, NC 28211-3138
Office: 704-364-8973
Fax: 704-364-8902
  Your Starting Address
Street Address
City, State or Zip
 
  Map Courtesy of Yahoo Maps(The map is a popup)
Name:
Email:
Phone:
Subject:
Recipient:
Message:
 
<% End If %>
Visit our main church website at www.charlotteadventistchurch.com