%
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''Replace everthing here that is in ALL CAPS from here '''''''''
''''''''' '''''''''
'domain="YOURDOMAINNAME.COM" '''''''''
'recipient_address="YOUREMAIL@YOURDOMAIN.COM, YOUROTHERADDRESS@YOURDOMAIN.COM" '''''''''
'''''''''can have multiple address seperated by a comma
''''''''' '''''''''
''''''''' '''''''''
''''''''' '''''''''
''''''''' replace TO HERE '''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''Do not edit below here unless you are familiar with ASP and VBScript''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''ntformmail.asp 1.1
''''by Claudio Weber
''''Bluehill Communications
''''3/16/2004
'Set intial varible values
dim body
subject = "WWW Form Submission"
title = "Thank You"
text_color = ""
'Check for unconfigured ntformmail.asp
If domain = "YOURDOMAINNAME.COM" then
error_report "Script misconfigured","This script needs the domain varible set at the top of the script."
End if
If instr(1,recipient_address,"YOUREMAIL@YOURDOMAIN.COM") > 0 then
error_report "Script misconfigured","Script misconfigured, missing email address at the top of the script."
End if
'Check for form options
For Each frmElement in request.form
response.write(frmElement & "->"&request.form(frmElement)&"
")
Select Case frmElement
Case "redirect"
redirect_url = request.form(frmElement)
add_to_message redirect_url
Case "subject"
subject = request.form(frmElement)
add_to_message subject
Case "email"
from_address = request.form(frmElement)
If instr(1,from_address,"@") = 0 or instr(1,from_address,".") = 0 then
error_redirect = "email|||"
end if
add_to_message from_address
Case "title"
title = request.form(frmElement)
add_to_message title
Case "realname"
from_name = request.form(frmElement)
add_to_message from_name
Case "alink_color"
alink_color = " alink=""" & request.form(frmElement) & """"
add_to_message alink_color
Case "vlink_color"
vlink_color = " vlink=""" & request.form(frmElement) & """"
add_to_message vlink_color
Case "link_color"
link_color = " link=""" & request.form(frmElement) & """"
add_to_message link_color
Case "text_color"
text_color = ""
add_to_message text_color
Case "bgcolor"
bgcolor = " bgcolor=""" & request.form(frmElement) & """"
add_to_message bgcolor
Case "background"
background = " background=""" & request.form(frmElement) & """"
add_to_message background
Case "required"
required = request.form("required")
add_to_message required
Case "env_report"
env_rep = split(request.form("env_report"),",")
for each env_var in env_rep
for each var in request.servervariables
if lcase(env_var)= lcase(var) then
env_blurb = env_blurb & env_var & ": " & request.servervariables(env_var) & "|||"
end if
next
next
Case "sort"
sort= request.form(frmElement)
add_to_message sort
Case "print_config"
add_to_message print_config
Case "print_blank_fields"
add_to_message print_blank_fields
Case "return_link_url"
add_to_message return_link_url
Case "return_link_title"
add_to_message return_link_title
Case "missing_fields_redirect"
add_to_message missing_fields_redirect
Case "submit"
add_to_message submit
Case else
'Build Message Body
If request.form("print_blank_fields")="1" then
body = body & frmElement &": " & request.form(frmElement) & "|||"
else
if request.form(frmElement) <> "" then
body = body & frmElement & ": " & request.form(frmElement) & "|||"
end if
end if
End Select
Next
arr_required = split(request.form("required"),",")
For each thing in arr_required
if thing = "email" and instr(1,error_redirect,"email|||") > 0 then
else
If request.form(thing)="" then
error_redirect = error_redirect & thing & "|||"
End if
end if
Next
If error_redirect <> "" then
If request.form("missing_fields_redirect") <> "" then
response.redirect(request.form("missing_fields_redirect"))
Else
error_report "Error: Blank Fields",error_redirect
End if
End if
body = body & env_blurb
If sort <> "" then
body_array = split(body,"|||")
If sort ="alphabetic" then
SortArray body_array
body = Join(body_array,"|||")
Else
Sort_by_order body_array
End if
if left(body,3)="|||" then
body= right(body,len(body)-3)
end if
End if
'Create mail object
Set Mail = Server.CreateObject("Persits.MailSender")
Mail.Host = domain
Mail.From = from_address
Mail.FromName = from_name
Mail.AddAddress recipient_address
Mail.Subject = subject
Mail.Body = replace(body,"|||",vbcrlf)
On Error Resume Next
Mail.Send
If Err<>0 Then
Response.Write"Error encountered:" & Err.Desciption
End If
If redirect_url <> "" then
response.redirect(redirect_url)
Else
success_display body
End if
''''''''''''''''''''''''''''''''''''''
Sub Sort_by_order(sort_array)
set oDict= createObject("Scripting.Dictionary")
For each thing in sort_array
If instr(1,thing,": ") then
thing_temp = split(thing,": ")
oDict.Add thing_temp(0), thing_temp(1)
else
oDict.Add thing, " "
end if
Next
If lcase(left(sort,6)) = "order:" then
sort = right(sort,len(sort)-6)
End if
sort_stuff = split(sort,",")
found = false
body = ""
For each thing in oDict
for each sort_item in sort_stuff
if lcase(thing) = lcase(sort_item) then
found = true
body = body & thing & ": " & oDict.Item(thing) & "|||"
end if
next
If found = false then
rest_of_body = rest_of_body & thing & ": " & oDict.Item(thing) & "|||"
end if
found = false
Next
set oDict= nothing
body = body & rest_of_body
End Sub
'''''''''''''''''''''''''''''''''''''''''''
Sub add_to_message(what_to_add)
what_to_add = cstr(what_to_add)
If instr(1,request.form(what_to_add),what_to_add) > 0 then
body = body & what_to_add & ": " & request.form(what_to_add) & "|||"
end if
End Sub
'''''''''''''''''''''''''''''''''''''''''''
Sub success_display(desc)
%>
<% success_results = split(desc,"|||") For each thing in success_results temp_results = split(thing,": ") response.write("" & text_color & temp_results(0) & ":" & "" & temp_results(1) & "
") Next %>
<% If request.form("return_link_title") <> "" or request.form("return_link_url") <> "" then response.write("" & request.form("return_link_title") & "") End if %>
<% Response.end End sub '''''''''''''''''''''''''''''''''''''''' Sub error_report(error_head,error_desc) title = "Error: Blank Fields" If error_head = "Script misconfigured" then title = "Script misconfigured" Else If request.form("return_link_title") <> "" then title = request.form("return_link_title") End if End if %>
| <%=text_color & title%> |
|---|
|
<%=error_desc%>
|
| <%=text_color%>The following fields were left blank in your submission form:
<%=text_color%> These fields must be filled in before you can successfully submit the form. Please use your browser's back button to return to the form and try again. |