Generic Email Form Handler using CDONTS
Email any form from your site using CDONTS (IIS's built-in smtp). Just 10 lines of code handles any size form! Email will display message in the form of fieldname: fieldvalue in proper tab order, with line breaks between each name/value pair.
Original Author: BebeZed
Inputs
Required form fields: Email, Subject. Email is the sender's email that will appear in the "From" field on the email. Both fields may hidden inputs if desired. Any number of other inputs may be added as desired.
Assumptions
Basic knowledge of html to set up the form is required. This code does not do anything after sending email, so you may want to redirect to another page or display a message that the mail was sent. Be sure to change "you@yourdomain.com" to your actual email address!
Code
<%
for i=1 to request.form.count
strMessage = strMessage & request.form.key(i) & ": " & request.form.item(i) & vbCrLf
Next
Set objMail = CreateObject("CDONTS.Newmail")
objMail.From = request.form("Email")
objMail.To = "you@yourdomain.com"
objMail.Subject = request.form("Subject")
objMail.Body = strMessage
objMail.Send
Set objMail = Nothing
%>
Loading Comments ...
Comments
No comments have been added for this post.
You must be logged in to make a comment.