%@ LANGUAGE="VBSCRIPT" %>
<% option explicit %>
<% Response.Buffer = True %>
<%
'Declaring Variables
Dim smtpserver,youremail,yourpassword,naam,emailadres,bedrijfsnaam
Dim adres,onderwerp,bericht,Action,IsError,nieuwsbrief
nieuwsbrief = "Ja"
' Edit these 3 values accordingly
smtpserver = "mail.publicip.nl"
youremail = "info@temacobv.nl"
yourpassword = "yourpassword"
' Grabbing variables from the form post
naam = Request("naam")
emailadres = Request("emailadres")
onderwerp = "E-mail via de website"
bericht = Request("bericht")
adres = Request("adres")
bedrijfsnaam = Request("bedrijfsnaam")
Action = Request("Action")
If Action = "SendEmail" Then
nieuwsbrief = Request("nieuwsbrief")
if nieuwsbrief <> "Ja" then
nieuwsbrief = "Nee"
End If
End If
' 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 = "SendEmail" Then
If naam = "" Then
IsError = "Yes"
End If
If IsValidEmail(emailadres) = "False" Then
IsError = "Yes"
End If
If onderwerp = "" Then
IsError = "Yes"
End If
If adres = "" 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
Dim strBody
' Here we create a nice looking html body for the email
strBody = strBody & "Contactformulier verstuurd op " & Now() & vbCrLf & "
"
strBody = strBody & "Van http://" & Request.ServerVariables("HTTP_HOST") & vbCrLf & "
"
strBody = strBody & "IP " & Request.ServerVariables("REMOTE_ADDR") & vbCrLf & "
"
strBody = strBody & "Naam" & " : " & " " & Replace(naam,vbCr,"
") & "
"
strBody = strBody & "Email" & " : " & " " & Replace(emailadres,vbCr,"
") & "
"
strBody = strBody & "Adres" & " : " & " " & Replace(adres,vbCr,"
") & "
"
' strBody = strBody & "Subject" & " : " & " " & Replace(onderwerp,vbCr,"
") & "
"
strBody = strBody & "Nieuwsbrief" & " : " & " " & Replace(nieuwsbrief,vbCr,"
") & "
"
strBody = strBody & "
" & Replace(bericht,vbCr,"
") & "
"
strBody = strBody & ""
dim cdoMessage, cdoConfig
set cdoMessage = Server.CreateObject("CDO.Message")
set cdoConfig = Server.CreateObject("CDO.Configuration")
cdoConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
cdoConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = smtpserver
cdoConfig.Fields.Update
set cdoMessage.Configuration = cdoConfig
cdoMessage.From = emailadres
cdoMessage.To = youremail
cdoMessage.Subject = onderwerp
cdoMessage.HtmlBody = strBody
on error resume next
cdoMessage.Send
if Err.Number <> 0 then
SendMail = "Email send failed: " & Err.Description & "."
end if
set cdoMessage = Nothing
set cdoConfig = 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.Redirect("/contact/bedankt.html")
%>
<% Else %>

<% End If %>