% Option Explicit '--- You can change these Const EMAIL_TO = "david@westpointscotland.com" Const EMAIL_FROM = "website@westpointscotland.com" Const EMAIL_SUBJECT = "Website Enquiry Form" Const MAIL_HOST = "127.0.0.1" '--- End - You can change these Dim iCommandID, bErrors, stErrorString, bEmailSent Dim stName, stCompany, stPosition, stAddress, stEmail, stTelephone, stRequirements, stNumberToDress, stBody Dim sch, cdoConfig, cdoMessage iCommandID = 0 If Request.Form("CommandID").Count > 0 Then iCommandID = CLng(Request.Form("CommandID")) Select Case iCommandID Case 2 With Request.Form stName = .Item("Name") stCompany = .Item("Company") stPosition = .Item("Position") stAddress = .Item("Address") stEmail = .Item("Email") stTelephone = .Item("Telephone") stRequirements = .Item("Requirements") stNumberToDress = .Item("Looking_to_dress") End With If Len(stName) < 3 Then AddError "Please enter your Name" If Len(stCompany) < 2 Then AddError "Please enter your Company Name" If Not checkValidEmail(stEmail) Then AddError "The email address you have supplied is not valid" If stNumberToDress = "x" Then AddError "Please select how many people you are looking to dress" If Not bErrors Then stBody = "Hello" & vbNewLine & vbNewLine & "A visitor to the Westpoint Website has just completed the Enquiry Form. Below are the details of their enquiry." & vbNewLine & vbNewLine & String(70, "-") & vbNewLine & vbNewLine & _ "Name: " & vbTab & stName & vbNewLine & _ "Company Name: " & vbTab & stCompany & vbNewLine If Len(stPosition) > 0 Then stBody = stBody & "Position: " & vbTab & stPosition & vbNewLine If Len(stAddress) > 0 Then stBody = stBody & "Address: " & vbTab & Replace(stAddress, vbCrLf, ", ") & vbNewLine stBody = stBody & "Email Address: " & vbTab & stEmail & vbNewLine If Len(stTelephone) > 0 Then stBody = stBody & "Telephone: " & vbTab & stTelephone & vbNewLine stBody = stBody & vbNewLine & "Requirements" & vbNewLine & "------------" & vbNewLine & stRequirements & vbNewLine & vbNewLine & _ "Looking to dress: " & vbTab & stNumberToDress & vbNewLine & vbNewLine & String(70, "-") sch = "http://schemas.microsoft.com/cdo/configuration/" Set cdoConfig = CreateObject("CDO.Configuration") With cdoConfig.Fields .Item(sch & "sendusing") = 1 ' pickup, 2 ' cdoSendUsingPort .Item(sch & "smtpserver") = MAIL_HOST .update End With Set cdoMessage = CreateObject("CDO.Message") With cdoMessage Set .Configuration = cdoConfig .From = EMAIL_FROM .To = EMAIL_TO .Subject = EMAIL_SUBJECT .TextBody = stBody .Send End With Set cdoMessage = Nothing Set cdoConfig = Nothing bEmailSent = True End If End Select %>
![]() ![]() |
|||||||||||||||||||||
|
|||||||||||||||||||||
|
|||||||||||||||||||||