/ Published in: ASP
Send an email from the server.
Expand |
Embed | Plain Text
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <% if Request.Form("submit") = "Send Email" then dim email set email = Server.CreateObject("CDO.Message") with email .Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 .Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost" 'if "localhost" doesn't work, use your mail server instead '.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.example.com" .Configuration.Fields.Update .Subject = Request.Form("subject") .TextBody = Request.Form("body") '.HTMLBody = Request.Form("body") 'use HTML instead of plain text err.clear on error resume next .From = Request.Form("fromAddress") .Send on error goto 0 if err.number <> 0 then 'fromAddress isn't a valid email address; send it from your generic "no reply" address instead .Send end if end with set email = Nothing end if %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Send Me An Email</title> </head> <body> <h1>Send me an email</h1> <form action="sendMeAnEmail.asp" method="post"> <table><tbody> <tr><td><label for="fromAddress">Your email address: </label></td> <td><input type="text" id="fromAddress" name="fromAddress"></td></tr> <tr><td><label for="subject">Subject: </label></td> <td><input type="text" id="subject" name="subject"></td></tr> <tr><td><label for="body">Body: </label></td> <td><textarea id="body" name="body"></textarea></td></tr> <tr><td></td> <td><input type="submit" name="submit" value="Send Email"></td></tr> </tbody></table> </form> </body> </html>
Comments
Subscribe to comments
You need to login to post a comment.

Updated to make it a working example.