 |

| |
<%
Dim strFrom, strSubject, strBody 'Strings for fromaddress, subject, body
Dim objCDOMail 'The CDO object
sch = "http://schemas.microsoft.com/cdo/configuration/"
Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
.Item(sch & "sendusing") = 2 ' cdoSendUsingPort
.Item(sch & "smtpserver") = "maxima11.abac.com"
.update
End With
'First we'll read in the values entered
strFrom = Request.Form("from")
'These would read the message subject and body if we let you enter it
strSubject = Request.Form("subject")
strBody = "Message : " + Request.Form("body") & vbCrLf & vbCrLf
strBody = strBody & "Contact Name: " & request.form("Name") & vbCrLf & vbCrLf
strBody = strBody & "Contact Email: " & request.form("from") & vbCrLf & vbCrLf
strBody = strBody & "Contact Telephone: " & request.form("Number") & vbCrLf & vbCrLf
' Some spacing
strBody = strBody & vbCrLf & vbCrLf
' Initiate Is email valid sub function
If strFrom = "" Or Not IsValidEmail(strFrom) Then
' Create Form
%>
<%
Else
' Create an instance of the NewMail object.
Set objMessage = Server.CreateObject("CDO.Message")
Set objMessage.Configuration = cdoConfig
' Set the properties of the object
objMessage.From = strFrom
objMessage.To = "info@bannerlabs.com"
objMessage.Subject = strSubject
objMessage.TextBody = strBody
' Some useful extra variables
'objMessage.Cc = "user@domain.com;user@domain.com"
'objMessage.Bcc = "user@domain.com;user@domain.com"
' Send the message!
objMessage.Send
' Set the object to nothing because it immediately becomes
' invalid after calling the Send method.
Set objMessage = Nothing
' Set your Response after the Send Mail button is pushed.
' Response.Write "Your Message was sent!"
Response.redirect "http://www.bannerlabs.com/thanks.html"
End if
' End page logic
%>
<% ' Only functions and subs follow!
' A quick email syntax checker.
Function IsValidEmail(strEmail)
Dim bIsValid
bIsValid = True
If Len(strEmail) < 5 Then
bIsValid = False
Else
If Instr(1, strEmail, " ") <> 0 Then
bIsValid = False
Else
If InStr(1, strEmail, "@", 1) < 2 Then
bIsValid = False
Else
If InStrRev(strEmail, ".") < InStr(1, strEmail, "@", 1) + 2 Then
bIsValid = False
End If
End If
End If
End If
IsValidEmail = bIsValid
End Function
%> |
|
 |