<%
'Set the response buffer to true so we execute all asp code before sending the HTML to the clients browser
Response.Buffer = True
'Dimension variables
Dim strBody 'Holds the body of the e-mail
Dim objJMail 'Holds the mail server object
Dim strMyEmailAddress 'Holds your e-mail address
Dim strSMTPServerAddress 'Holds the SMTP Server address
Dim strCCEmailAddress 'Holds any carbon copy e-mail addresses if you want to send carbon copies of the e-mail
Dim strBCCEmailAddress 'Holds any blind copy e-mail addresses if you wish to send blind copies of the e-mail
Dim strReturnEmailAddress 'Holds the return e-mail address of the user
Dim strIP = request.ServerVariables("REMOTE_ADDR") 'Get the Users IP address
'----------------- Place your e-mail address in the following sting ---------------------------------
strMyEmailAddress = "my email address"
'---------- Place the address of the SMTP server you are using in the following sting ---------------
strSMTPServerAddress = "server addresss..."
'-------------------- Place Carbon Copy e-mail address in the following sting ------------------------
strCCEmailAddress = "" 'Use this string only if you want to send the carbon copies of the e-mail
'-------------------- Place Blind Copy e-mail address in the following sting -------------------------
strBCCEmailAddress = "" 'Use this string only if you want to send the blind copies of the e-mail
'-----------------------------------------------------------------------------------------------------
'Read in the users e-mail address
strReturnEmailAddress = Request.Form("email")
'Get the IP address of the sender
Request.ServerVariables("REMOTE_ADDR")
'Initialse strBody string with the body of the e-mail
strBody = "<h2>Website Inquiry</h2>"
strBody = strBody & "<br><b>Name: </b>" & Request.Form("firstName") & " " & Request.Form("lastName")
strBody = strBody & "<br><br><b>Address: -</b>"
If (Request.Form("street1")) > "" Then
strBody = strBody & "<br> " & Request.Form("street1")
End If
If (Request.Form("street2")) > "" Then
strBody = strBody & "<br> " & Request.Form("street2")
End If
If (Request.Form("town")) > "" Then
strBody = strBody & "<br> " & Request.Form("town")
End If
If (Request.Form("county")) > "" Then
strBody = strBody & "<br> " & Request.Form("county")
End If
If (Request.Form("country")) > "--- Choose One ---" Then
strBody = strBody & "<br> " & Request.Form("country")
End IF
If (Request.Form("postCode")) > "" Then
strBody = strBody & "<br> " & Request.Form("postCode")
End If
strBody = strBody & "<br><br><b>Telephone: </b>" & Request.Form("tel")
strBody = strBody & "<br><b>E-mail: </b>" & strReturnEmailAddress
strBody = strBody & "<br><br><b>Enquiry: - </b><br>" & Replace(Request.Form("enquiry"), vbCrLf, "<br>")
'Check to see if the user has entered an e-mail address and that it is a valid address otherwise set the e-mail address to your own otherwise the e-mail will be rejected
If Len(strReturnEmailAddress) < 5 OR NOT Instr(1, strReturnEmailAddress, " ") = 0 OR InStr(1, strReturnEmailAddress, "@", 1) < 2 OR InStrRev(strReturnEmailAddress, ".") < InStr(1, strReturnEmailAddress, "@", 1) Then
'Set the return e-mail address to your own
strReturnEmailAddress = strMyEmailAddress
End If
'Send the e-mail
'Create the e-mail server object
Set objJMail = Server.CreateObject("JMail.SMTPMail")
'Out going SMTP mail server address
objJMail.ServerAddress = strSMTPServerAddress
'Senders email address
objJMail.Sender = strReturnEmailAddress
'Senders name
objJMail.SenderName = Request.Form("firstName") & " " & Request.Form("lastName")
'Who the email is sent to
objJMail.AddRecipient strMyEmailAddress
'Who the carbon copies are sent to
objJMail.AddRecipientCC strCCEmailAddress
'Who the blind copies are sent to
objJMail.AddRecipientBCC strBCCEmailAddress
'Set the subject of the e-mail
objJMail.Subject = "Enquiry sent from enquiry form on website"
'Set the main body of the e-mail (HTML format)
objJMail.HTMLBody = strBody
'Set the main body of the e-mail (Plain Text format)
'objJMail.Body = strBody
'Importance of the e-mail ( 1 - highest priority, 3 - normal, 5 - lowest)
objJMail.Priority = 3
'Send the e-mail
objJMail.Execute
'Close the server object
Set objJMail = Nothing
%>