Faux by Kathy Newsletter Sign-up |
|
|
<% If request.form("btnSubmit") <> "" then
'Declare variables for the e-mail script
dim email
dim replyTo
dim subject
dim message
dim name
dim isValid
isValid = true
'Get input from the form and assign it to script variables
email = Trim(Request.form("email_addr"))
if email <> "" then
replyTo = cstr(email)
end if
name = Request.form("first_name") & " " & Request.form("last_name")
subject = "Newletter subscription request"
message = name & " (" & email & ") would like to subscribe to the newsletter"
'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 (email <> "" AND name <> "") then
send_email()
Response.end
else
isValid = false
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 = "kathy@gofaux.com"
objMail.From = "kathy@gofaux.com" 'Generic email address can tell you what form msg is from
objMail.ReplyTo = replyTo
objMail.Subject = subject
objMail.TextBody = message
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
Response.Write "You have successfully subscribed to the newsletter! Thank you for your interest!" &_
"Return to the main site "
end if
end function
else
isValid = true
end if %>
<%
if (not isValid) then
Response.Write "Please complete required fields!"
end if
%>
|
|
|