Feedback form with CDOSYS in Classic ASP

A feedback or contact form normally has two parts: an HTML form that collects visitor input and a server-side ASP page that validates the submitted fields and sends or stores the message.

This legacy Classic ASP example uses CDO.Message (CDOSYS). CDOSYS availability and SMTP configuration depend on the Windows/IIS environment, so confirm that your server supports and configures it before using the mail portion.

Feedback form

<form method="post" action="feedback2.asp">
  <label for="fname">Name</label>
  <input type="text" id="fname" name="fname" required>
  <label for="email">Email</label>
  <input type="email" id="email" name="email" required>
  <label for="add1">Address 1</label>
  <input type="text" id="add1" name="add1">
  <label for="add2">Address 2</label>
  <input type="text" id="add2" name="add2">
  <label for="city">City</label>
  <input type="text" id="city" name="city">
  <label for="state">State</label>
  <input type="text" id="state" name="state">
  <label for="country">Country</label>
  <input type="text" id="country" name="country">
  <label for="message">Feedback</label>
  <textarea id="message" name="message" rows=5 required></textarea>
  <button type="submit">Submit</button>
</form>
On this page — Show page sectionsHide page sections

Receive, validate and send the message

Dim visitorName, email, add1, add2, city, state, country, message, bodyText, plusMail
visitorName = Trim(Request.Form("fname"))
email = Trim(Request.Form("email"))
add1 = Trim(Request.Form("add1"))
add2 = Trim(Request.Form("add2"))
city = Trim(Request.Form("city"))
state = Trim(Request.Form("state"))
country = Trim(Request.Form("country"))
message = Trim(Request.Form("message"))

If Len(visitorName) = 0 Or Len(message) = 0 Then
  Response.Write "Please complete the required fields."
  Response.End
End If

bodyText = "Name: " & Server.HTMLEncode(visitorName) & "<br>" & _
           "Email: " & Server.HTMLEncode(email) & "<br>" & _
           "Address 1: " & Server.HTMLEncode(add1) & "<br>" & _
           "Address 2: " & Server.HTMLEncode(add2) & "<br>" & _
           "City: " & Server.HTMLEncode(city) & "<br>" & _
           "State: " & Server.HTMLEncode(state) & "<br>" & _
           "Country: " & Server.HTMLEncode(country) & "<br>" & _
           "Message: " & Server.HTMLEncode(message)

Set plusMail = CreateObject("CDO.Message")
plusMail.Subject = "Website feedback"
plusMail.From = "website@example.com"
plusMail.To = "siteadmin@example.com"
plusMail.HtmlBody = bodyText
plusMail.Send
Set plusMail = Nothing

Do not use a visitor-supplied email address directly as the message's From header. Many mail systems reject or distrust that pattern, and unvalidated header fields can create security problems. Use an address controlled by your site and, if your mail setup supports it, place the validated visitor address in a reply-to field.

For a public form, also consider abuse controls such as rate limiting, spam protection, request-size limits, logging, and a clear privacy policy.

Reject a blank name on the server

Dim visitorName
visitorName = Trim(Request.Form("fname"))
If Len(visitorName) = 0 Then
    Response.Write "Please enter your name."
    Response.End
End If

Browser required attributes help usability, but only server-side checks protect the form-processing endpoint.

Secure a public feedback form

Validate submitted fields on the server, limit message length, use anti-spam/rate limiting, and keep the message sender address fixed to a domain you control. Do not inject raw visitor input into mail headers or HTML.

Back to top ↑


ASP Home






✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer