<%
'*******************************************************
'Background to this script
'*******************************************************
'
'Author: Yashodhan
'Date: 22 August 2002
'Company: Yashodhan P Bhadsawale, Mumbai
'E-Mail: yashodhanb@rediffmail.com
'Web Site: http://www.ekmev.com
'
'Keep an eye out for updates to this script with multi-
'mail components, more functionality and customisation.
'
'*******************************************************
'INSTALLATION AND CONFIGURATION
'*******************************************************
'
'This script is provided as is. Modify the code to
'suit your needs but it is set up to be as easy to
'install and use as possible.
'
'This script should be placed on a windows server
'with support for CDONTS and ASP. The idea of this
'script is that you can send a mail to whoever you
'want, like a feedback form without having to
'rewrite the script that actually sends the e-mail
'each time you want to do this.
'
'Place this file on any directory and call it
'sendmail.asp. Set up as many other pages as you
'want that will use this script to send feedback.
'Even allow multiple sites to use the same script on
'your web site to send feedback. Set up a form on
'another page with whatever text boxes, select
'boxes, text areas, etc.
'
'Included in your form should be the following
'hidden fields: mail_from, mail_to, mail_cc,
'mail_bcc, mail_subject, mail_importance,
'mail_redirect. The values of these hidden fields
'will determine who the mail goes to, who it's from,
'subject, redirection to thank you page, etc.
'There are defaults if values are empty but if you
'do not enter a value in the mail_to hidden field
'the mail WILL NOT send.
'
'All that is left to do is point your feedback
'form to this page and let the script do the rest.
'Follow these instructions and you won't have to
'edit any asp code at all. There is a sample feedback
'form below to get you started as well.
'
'ENJOY!!!!
'
'*******************************************************
'*******************************************************
'Get values from hidden fields for sending the mail
'*******************************************************
form_from = Request.Form("mail_from") 'who is the mail from, e.g. feedback@yoursite.com
form_to = Request.Form("mail_to") 'who is the mail to, e.g. info@yourcompany.com
form_cc = Request.Form("mail_cc") 'leave blank if not needed! who is the carbon copy to be sent to, e.g. joe@yourcompany.com
form_bcc = Request.Form("mail_bcc") 'leave blank if not needed! who is the blind carbon copy to be sent to, e.g. karen@yourcompany.com
form_subject = Request.Form("mail_subject") 'text to appear in subject line of the e-mail
form_importance = Request.Form("mail_importance") 'importance of the e-mail. Must be a number 0, 1 or 2. 2 = High, 1 = Normal, 0 = Low
form_redirect = Request.Form("mail_redirect") 'page to redirect to after sending e-mail, e.g. http://yoursite.com/thankyou.htm
'*******************************************************
'If values are empty, put in some defaults
'*******************************************************
IF form_from = "" THEN form_from = "Webmaster "
IF form_to = "" THEN form_to = ""
IF form_cc = "" THEN form_cc = ""
IF form_bcc = "" THEN form_bcc = ""
IF form_subject = "" THEN form_subject = "Dynamic Feedback"
IF form_importance = "" THEN form_importance = 1
IF form_redirect = "" THEN form_redirect = ""
'*******************************************************
'Get all form elements and structure the e-mail
'*******************************************************
For Each x_value In Request.Form
IF x_value = "mail_from" OR x_value = "mail_to" OR x_value = "mail_cc" OR x_value = "mail_bcc" OR x_value = "mail_subject" OR x_value = "mail_importance" OR x_value = "mail_redirect" THEN
form_variables = form_variables
ELSE
form_variables = form_variables & x_value & ": " & vbcrlf & Request.Form(x_value) & vbcrlf & vbcrlf
END IF
Next
DIM body_text
body_text = vbcrlf & "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" & vbcrlf
body_text = body_text & "Feedback from your ekmev.com" & vbcrlf
body_text = body_text & "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" & vbcrlf & vbcrlf
body_text = body_text & form_variables & vbcrlf & vbcrlf
body_text = body_text & "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" & vbcrlf
body_text = body_text & "Script Provided by Yashodhan Web Creations" & vbcrlf
body_text = body_text & "http://www.ekmev.com" & vbcrlf
'*******************************************************
'Get values from hidden fields for sending the mail
'*******************************************************
SET objMail = Server.CreateObject("CDONTS.NewMail")
objMail.BodyFormat = 1
objMail.MailFormat = 1
objMail.From = form_from
objMail.To = form_to
objMail.CC = form_cc
objMail.BCC = form_bcc
objMail.Subject = form_subject
objMail.Importance = form_importance
objMail.Body = body_text
objMail.Send 'This line actually sends the e-mail
SET objMail = NOTHING
'*******************************************************
'Redirect to thank you page or write thank you
'*******************************************************
IF form_redirect = "" THEN
Response.Write("")
ELSE
Response.Redirect(form_redirect)
END IF
'*******************************************************
'There is a sample Feedback Form below to start you off.
'That's it. Hope you benefit from it. Happy Mailing!
'*******************************************************
%>