Web Development

  Homes arrow Web Development arrow Sending form values to an email
 Webmaster Tools
Base64 Encoding 
Browser Settings 
CSS Coder 
CSS Navigation Menu 
Datetime Converter 
DHTML Tooltip 
Dig Utility 
DNS Utility 
Dropdown Menu 
Fetch Content 
Fetch Header 
Floating Layer 
htaccess Generator 
HTML Encoder 
HTML Entities 
IP Convert 
Meta Tags 
Password Encryption
Password Strength
Pattern Extractor 
Ping Utility 
Pop-Up Window 
Regex Extractor 
Regex Match 
Scrollbar Color 
Source Viewer 
Syntax Highlighting 
URL Encoding 
Web Safe Colors 
Forums Sitemap 
Weekly Newsletter
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Contact Us 
Site Map 
Privacy Policy 
  >>> SIGN UP!  
  Lost Password? 

Sending form values to an email
By: Developer Shed
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 5

    Table of Contents:

    Rate this Article: Poor Best 
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article




    by: Codefixer.com

    Sending form values to an email

    Copy the 2 pages below and paste them into the same folder and then run form.html on your webserver (this won't work on your personal webserver, must be an internet server and support the CDONTS mail object). If you fill in the text boxes on the form.html page and click submit then the values entered will be sent to form_ac.asp. Form_ac.asp will be the page that will receive and process the values entered into the text boxes.
    In our example once the variables have been received by form_ac.asp an email will then be sent which holds the variables. The comments in the pages should explain the code.

    Call this page form.html
    <title>form to email script</title>
    <body bgcolor="#FFFFFF">

    <div align='center'>
    <form method="POST" action="form_ac.asp" name="form1">
    <table width="75%" border="0" cellspacing="0" cellpadding="0">
    <td><font face="Verdana, Arial, Helvetica, sans-serif" size="2">name:</font></td>
    <td colspan="2">
    <input type="text" name="name">
    <td><font face="Verdana, Arial, Helvetica, sans-serif" size="2">email:</font></td>
    <td colspan="2">
    <input type="text" name="email">
    <td><font face="Verdana, Arial, Helvetica, sans-serif" size="2">message:</font></td>
    <td colspan="2">
    <textarea name="message" cols="40" rows="5"></textarea>
    <td colspan="2">
    <input type="submit" name="Submit" value="Submit">
    <input type="reset" name="Reset" value="Reset">


    Call this page form_ac.asp (the ac is short for acquire as it will be receiving values)

    <% @ Language="VBscript" %>
    <% Option Explicit %>

    <title>Message Sent</title>

    <body bgcolor="#FFFFFF">
    'receive the values sent from the form and assign them to variables...
    'declare the variables that will receive the values
    'note that request.form("name") will receive the value entered into the textfield
    'called name, and so with email and message
    m name, email, message, NewMailObj


    'create the mail object and send the details
    Set NewMailObj=Server.CreateObject("CDONTS.NewMail")
    NewMailObj.From = "michael@codefixer.com"
    NewMailObj.To = "whoever_you_want_to_send_it_to@hotmail.com"
    NewMailObj.Subject = "New message sent.."
    NewMailObj.Body = "the name you entered was " & name & _
    "<br>the email was " & email & _
    "<br>the message was " & message

    'you need to add the following lines FOR the mail to be sent in HTML format
    NewMailObj.BodyFormat = 0
    NewMailObj.MailFormat = 0
    'Close the email object and free up resources
    Set NewMailObj = nothing

    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">The email was sent.</font>


    You may be interested in reading our tutorial 'Insertform content into a database'

    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

    More Web Development Articles
    More By Developer Shed



    - On Page SEO for New Domains
    - Improve Your Site`s Speed
    - Safari Books Online Review
    - Creating an Estore From the Ground Up
    - Most Common SEO Mistakes Developers Make
    - Making the Most of Your Titles and Meta Desc...
    - Five Ways Using Flash Can Damage Your Site
    - A Web Designer`s Guide to Colors
    - Use Webstarts to Create a Free Site
    - More Than Just Looks. How Your Web Design C...
    - How to Design Content Pages
    - Mint Review
    - Make Your WordPress Website Look Professional
    - How to Create a Mobile Web Site
    - Meta Tags: Still Useful?

    Developer Shed Affiliates


    © 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap