We have an area on our website that has quite a large form for staff to fill in. The user then adds their e-mail address and the recipients e-mail address and then sends the form as an e-mail. The problem is the formating of the e-mail when it arrives. It does not look very good. I need it to be layed out like the form. Is there a way of doing this?
I am using formmail to send the form. Code below:
<%@ Language = vbscript%>
<%option explicit %>
<%server.scripttimeout = 600 %>
<%
'################################################################################################### #
'this is where the code starts for real
'################################################################################################### #
'--------------------------------------------------------------------------------------------------- -
'declare variables
'--------------------------------------------------------------------------------------------------- -
Dim strFrom, strTo, strSubject, strBody
Dim objMessage, objConfig, strServer, intPort
Dim recipient, redirect, subject, realname, email, required, strEmail1, strEmail2
Dim referer, url, url_verified, icounter, query, iloop, query2, query3, i, agree, validation, error0, error0ok
'############################## CONFIGURATION VARIABLES ####################################
'These are the only lines you will need to change
'--------------------------------------------------------------------------------------------------- -
strServer = "smtp.our server" 'set which smtp server will be used to send the email. enter ip address or domain name. eg: "xxx.xxx.xxx.xxx" or "smtp.your-domain.com"
intPort = 25 'set the smtp port to be used when sending mail (by default port 25 is used)
'Referrer's Array is defined here. Enter the valid domains which may use this script.
url = Array("
www.sccs.camden.sch.uk")'Set which urls that will be accepted.
http://xxxxx/ 'Seperate multiple domains by commas
'eg: url= Array("
www.your-domain.com","your-domain.com","www.my-domain.com")
'computer names can be used instead of domains if this script is being run locally
'eg: url = Array("computername")
'######################################### IMPORTANT NOTICE #########################################
'IMPORTANT: do not modify anything below this line unless you know what you are doing!!
'######################################### IMPORTANT NOTICE #########################################
'--------------------------------------------------------------------------------------------------- -
'information type and CDOSYS constants
'--------------------------------------------------------------------------------------------------- -
%>
<!--METADATA TYPE="typelib"
UUID="CD000000-8B95-11D1-82DB-00C04FB1625D"
NAME="CDO for Windows 2000 Library" -->
<!--METADATA TYPE="typelib"
UUID="00000205-0000-0010-8000-00AA006D2EA4"
NAME="ADODB Type Library" -->
<%
'--------------------------------------------------------------------------------------------------- -
'retrieved default fields
'--------------------------------------------------------------------------------------------------- -
recipient = request("recipient")
redirect = request("redirect")
subject = request("subject")
email = request("email")
required = request("required")
if required = "" then
required = "recipient,subject,email,redirect"
else
required = "recipient,subject,email,redirect," & required
end if
'--------------------------------------------------------------------------------------------------- -
'verify the referer
'--------------------------------------------------------------------------------------------------- -
referer = request.ServerVariables("HTTP_REFERER")
referer = split(referer,"/")
url_verified = "no"
for icounter = Lbound(url) to Ubound(url) '
if referer(2) = url(icounter) then
url_verified = "yes"
end if
next
if not url_verified = "yes" then
response.write("The url specified is invalid!")
response.End
end if
'--------------------------------------------------------------------------------------------------- -
'verify the recipient(not tested)
'--------------------------------------------------------------------------------------------------- -
'trimed_referer = split(referer(2),".")'
'response.write recipient & "<br>" & referer(2) & "=" & trimed_referer(0) & "<br>"
'if trimed_referer(0) = "www" then
' if InStr(1,recipient,trimed_referer(1),1) = 0 then
' response.write "recipient don't match the referer"
' response.end
' end if
'else
' if InStr(1,recipient,trimed_referer(0),1) = 0 then
' response.write "recipient don't match the referer"
' response.end
' end if
'end if
'--------------------------------------------------------------------------------------------------- -
'retrieve form contents and create email fields
'--------------------------------------------------------------------------------------------------- -
query = Request.ServerVariables("QUERY_STRING")
query = split(query,"&")
query3 = split(required,",")
For iLoop = Lbound(query) to UBound(query)
query2 = split(query(iloop),"=")
'--------------------------------------------------------------------------------------------------- -
'form validation, checks required fields are not null
'--------------------------------------------------------------------------------------------------- -
for i = LBound(query3) to UBound(query3)
if query3(i) = query2(0) then
if query2(1) = "" then
response.write ("you must enter a valid ") & query2(0)
response.end
end if
end if
'if query2(0) = "agree" then
'if query2(1) <> "on" or query2(1) = "" then
' response.write("You must agree to terms and conditions to enable Formmailv1.3 to execute!")
'response.end
'end if
'end if
'--------------------------------------------------------------------------------------------------- -
'form validation, checks a valid email address has been specified
'--------------------------------------------------------------------------------------------------- -
if query2(0) = "email" then
trim(query2(0))
if len(query2(1))<8 then
response.Write("You must specify a valid ") & query2(0)
response.end
end if
if instr(query2(1),"@")=0 and instr(query2(1),".")=0 then
response.write query2(1)
response.Write("You must specify a valid ") & query2(0)
response.end
end if
strEmail1 = split(query2(1),"@")
&n