Form to mail: CDONTS Mail(.asp)

Example 1

Would you like to get on your email all the information included in a form?

  • First of all you need a form, as for example the one in the table:
form.html
<FORM ACTION="formtomail.asp" METHOD=post>

<!-- Your fields here -->

<INPUT TYPE=submit value="Submit">
</FORM>

    The Form Action must be directed to the ASP script bellow.
  • Second: you need the asp script (copy the information in the table to a text file 
    and save the file as "formtomail.asp" in your server).
formtomail.asp
<%
Set objcdo = Server.CreateObject("CDONTS.NewMail")
objcdo.To = "youremail@yourdomain.com"
objcdo.From = "formtomail@yourdomain.com"
objcdo.Subject = "Email Sent From My Site"
objcdo.Body = Request.Form("mymessage")
objcdo.MailFormat = 0
objcdo.BodyFormat = 0
objcdo.Importance = 1
objcdo.Send
objcdo.Redirect ("http://www.mysite.com")
Set objcdo = Nothing
%>
You need to customize the script:
  • Change youremail@yourdomain.com, and write the email to which you want the information to be send.
  • Instead of formtomail@yourdomain.com, write the email from which the information is send. 
    In case you are asking to your visitor to write their email in the form (p.e.  using a field like this: <input type="text" name="email">, you may write "request.for("email")" instead of "formtomail@yourdomain.com".That way you will get un email from the person filling the form.
  • "Email Sent From My Site" will be the subject of the email you will get.
  • "Request.Form("mymessage")" is the message input name of your email form. Change "mymessage" to your message input name.
  • "objcdo.MailFormat" is the email type. 0 = MIME and 1 = Text
  • If you will set "objcdo.MailFormat = 0" then you must set "objcdo.BodyFormat = 0". 0 = HTML and 1 = TEXT
  • "objcdo.Importance = 1" is the Mail Sending Importance. 0 = Low , 1 = Normal , 2 = High
  • This script will redirect the response to a different page. Whatever you want to unswer to the person who has fill the form must be writen in a html page. Write this url in the script (change "http://www.yoursite.com").
NOTE: You may have problems with this script in your server in case "CDONTS" instruction is not supported by your server but it is a default mail sending support. In that case you will need to contact to your server administrator. 




Google






   



MSN Nick Name



More Resources...





Most Viewed Services:
  1. HTML Tutorial
  2. XHTML Tutorial
  3. CSS Tutorial
  4. Javascript Tutorial
  5. DHTML Tutorial
  6. VB Script
  7. TCP/IP Tutorial
  8. ADO Tutorial
  9. MYSQL Tutorial
  10. ASP Tutorial
  11. AJAX Tutorial
  12. CFML Tutorial
  13. PHP Tutorial
  14. WML Tutorial
  15. FLASH Tutorial
  16. XML Tutorial
  17. RSS Tutorial
  18. SQL Tutorial
  19. HTML Articles
  1. Javascript Articles
  2. PHP Articles
  3. SEO Articles
  4. Web Design Articles
  5. SEO Tips
  6. Web Design Tips
  7. Articles
  8. CSS
  9. CSS Tips
  10. HTML Tips
  11. JAVASCRIPT Tips
  12. MYSQL Tips
  13. PHP Tips
  14. Money
  15. Tutorials
  16. Web Hosting



  • Home
  • Web Directory
  • Top Directoriers
  • Webmaster Directories
  • Contact
  • © Copyright 2006-2010 All Rights Reserved By CodeDcode.Com : HTML : RSS : TEXT : XML