%
SUB sendmail( fromWho, toWho, Subject, Body )
Dim objCDO
Dim iConf
Dim Flds
Const cdoSendUsingPort = 2
Set objCDO = Server.CreateObject("CDO.Message")
Set iConf = Server.CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
With Flds
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "mail-fwd"
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPconnectiontimeout) = 10
.Update
End With
Set objCDO.Configuration = iConf
objCDO.From = fromWho
objCDO.To = toWho
objCDO.Subject = Subject
objCDO.TextBody = Body
objCDO.Send
'Cleanup
Set ObjCDO = Nothing
Set iConf = Nothing
Set Flds = Nothing
END SUB
function chkEmail(theAddress)
' checks for a vaild email
' returns 1 for invalid addresses
' returns 0 for valid addresses
dim atCnt
chkEmail = 0
' chk length
if Len(theAddress) < 5 then
' a@b.c should be the shortest an
' address could be
chkEmail = 1
' chk format
' has at least one "@"
elseif instr(theAddress,"@") = 0 then
chkEmail = 2
' has at least one "."
elseif instr(theAddress,".") = 0 then
chkEmail = 3
' has no more than 3 chars after last "."
elseif len(theAddress) - instrrev(theAddress,".") > 3 then
chkEmail = 4
' has no "_" after the "@"
elseif instr(theAddress,"_") <> 0 and _
instrrev(theAddress,"_") > instrrev(theAddress,"@") then
chkEmail = 5
else
' has only one "@"
atCnt = 0
for i = 1 to len(theAddress)
if mid(theAddress,i,1) = "@" then
atCnt = atCnt + 1
end if
next
if atCnt > 1 then
chkEmail = 6
end if
' chk each char for validity
for i = 1 to len(theAddress)
if not isnumeric(mid(theAddress,i,1)) and _
(lcase(mid(theAddress,i,1)) < "a" or _
lcase(mid(theAddress,i,1)) > "z") and _
mid(theAddress,i,1) <> "_" and _
mid(theAddress,i,1) <> "." and _
mid(theAddress,i,1) <> "@" and _
mid(theAddress,i,1) <> "-" then
chkEmail = 7
end if
next
end if
end function
dim companyname
dim name
dim address
dim city
dim state
dim phone
dim zip
dim fax
dim email
dim comments
dim bweight
dim wwidth
dim diameter
dim core
dim order
dim submitted
submitted = false
'required fields
companyname = trim(Request.Form("companyname"))
name = trim(Request.Form("name"))
email = trim(Request.Form("email"))
'optional fields
address = trim(Request.Form("address"))
city = trim(Request.Form("city"))
state = trim(Request.Form("state"))
phone = trim(Request.Form("phone"))
zip = trim(Request.Form("zip"))
fax = trim(Request.Form("fax"))
comments = trim(Request.Form("comments"))
bweight = trim(Request.Form("bweight"))
wwidth = trim(Request.Form("wwidth"))
diameter = trim(Request.Form("diameter"))
core = trim(Request.Form("core"))
order = trim(Request.Form("order"))
if Request.Form("submit") = "Submit" then
submitted = true
end if
if submitted and name <> "" and companyname <> "" and phone <> "" then
'user successfully filled out the form
dim body
body = ""
dim email_code
email_code = chkEmail(email)
if email_code <> 0 then
body = body + "Email As Entered(" + cstr(email_code) + "): " + email + chr(10) + chr(13)
email = "unknown@papersalesusa.com"
end if
body = body + "Company Name: " + companyname + chr(10) + chr(13)
body = body + "Name: " + name + chr(10) + chr(13)
body = body + "Address: " + address + chr(10) + chr(13)
body = body + city + "," + state + " " + zip + chr(10) + chr(13)
body = body + chr(10) + chr(13) + "Phone: " + phone + chr(10) + chr(13)
body = body + "Fax: " + fax + chr(10) + chr(13)
body = body + "Comments: '" + comments + "'" + chr(10) + chr(13)
body = body + chr(10) + chr(13) + "Order Information: " + chr(10) + chr(13)
body = body + "Basis Weight: " + bweight + chr(10) + chr(13)
body = body + "Web Width: " + wwidth + chr(10) + chr(13)
body = body + "Diameter: " + diameter + chr(10) + chr(13)
body = body + "Core: " + core + chr(10) + chr(13)
body = body + "Order Comments: '" + order + "'" + chr(10) + chr(13)
body = body + chr(10) + chr(13) + chr(10) + chr(13) + "The email was auto-generated from www.papersalesusa.com."
sendMail email, "info@papersalesusa.com", "Papers Sales USA Lead", Body
' sendMail email, "gabe@cleokat.com", "Papers Sales USA Lead", Body
Response.Redirect("/thankyou.html")
end if
%>