% ' #### This script Copyright (c) 2001 ASPjar.com, All Rights Reserved. NO WARRANTEE. ' #### You need CDONTS installed to be able to send mail ' #### Your sites information starts here #### ' Your Email Address - must be a valid domain or the mail will not send sYouEmail="josephine.ho@cem-macau.com" ' Email Subject EmailSubject="Someone has used the contact form" ' Heading font color FontColor="#5e007f" ' Heading Background Color HeadColor="#ffc500" ' Form Font Color FormFontColor="#ffc500" ' Form Background Color FormBackColor="#5e007f" 'Error Message Color ErrorColor="red" ' That's it! - you may now wish to customize the header and footer files to suit your site. ' #################################################################################### Function ValidateField(sFieldvalue, sFieldtype) ValidField = true Select Case LCase(sFieldtype) Case "name" If Len(sFieldvalue) = 0 Then ValidField = False Case "email" If Len(sFieldvalue) < 5 Then ValidField = False Else If InStr(1, sFieldvalue, "@", 1) < 2 Then ValidField = False Else If InStr(1, sFieldvalue, ".", 1) < 4 Then ValidField = False End If End If End If Case "message" If Len(sFieldvalue) = 0 Then ValidField = False Case "else" ValidField = False End Select ValidateField = ValidField End Function Sub ShowForm %>
<%
End Sub
Sub Send
sPunter = Request.Form("Name")
sPunterEmail = Request.Form("Email")
Message = Request.Form("message")
If Request.Form("agree") = "true" then
Mailout = "They wish to be included on the mailing list"
Else
Mailout ="They DO NOT wish to be included on the mailing list"
End If
sMessage = "This is a message from " & sPunter & vbcrlf _
& vbcrlf _
& vbcrlf _
& Message & vbcrlf _
& vbcrlf _
& "Their email is: " & sPunterEmail & vbcrlf _
& vbcrlf _
& Mailout & vbcrlf _
& vbcrlf
Set objNewMail = CreateObject("CDONTS.NewMail")
objNewMail.Send sPunterEmail, sYouEmail, EmailSubject, sMessage
Set objNewMail = Nothing
End Sub
Set dictFields = Server.CreateObject("Scripting.Dictionary")
For Each Field in Request.Form
If ValidateField(Request.Form(Field), Field) = False Then
dictFields.Add LCase(Field), true
End If
Next
If Request.Form.Count <> 0 And dictFields.Count = 0 Then
%>
Your message has been mailed!
Thank you for contacting us. A reply will be sent soon.
<%
Call Send
Else
ShowForm
End If
%>