|
<%@language="VBScript"%>
Feedback
<% If request.form("btnSubmit") <> "" then
'Declare variables for the e-mail script
dim replyTo
dim strSubject
dim strText
'Get input from the form and assign it to script variables
strAddr = Trim(Request.form("user_email"))
if strAddr <> "" then
replyTo = cstr(strAddr)
end if
strSubject = Request.form("user_subject")
strName = Request.form("user_name")
strMsg = Request.form("user_text")
strText = strName & vbCrLf & "E-mail from: " & strAddr & vbCrLf & "Comments: " & strMsg
'Note: use vbCrLf (as above) to add line breaks in the e-mail message
'A real form might check for more blank fields and a valid e-mail address.
'Form has been submitted after JavaScript validation, but if JavaScript off, server also validates
If (replyTo <> "" AND strMsg <> "") then
send_email()
else
Response.Write "Please complete required fields!"
end if
'The send_email function formats and sends the e-mail
function send_email()
'Create an object or container for your mail
Dim objMail
Set objMail = Server.CreateObject("CDO.Message")
'Format the e-mail using fields from your HTML form
objMail.To = "laura.con40@gmail.com"
objMail.From = "Greek Ethos@whatever.com" 'Generic email address can tell you what form msg is from
objMail.ReplyTo = replyTo
objMail.Subject = strSubject
objMail.TextBody = strText
objMail.Send
'Release system resources
Set objMail = Nothing
if err.number > 0 then
response.write "Errors were encountered in sending your e-mail message. "&_
"Please try again, or contact the webmaster"
else
'You could use a JavaScript alert or write a confirmation to the screen. Sample javascript alert is shown in next line.
'Response.Write ""
Response.Write "Thank you for your submission!"
Response.Write "Return to form "
end if
end function
else
'display the form
%>
<%
end if
%> |