logo
g Text Version
Beauty & Self
Books & Music
Career
Computers
Education
Family
Food & Wine
Health & Fitness
Hobbies & Crafts
Home & Garden
Money
News & Politics
Relationships
Religion & Spirituality
Sports
Travel & Culture
TV & Movies

dailyclick
Bored? Games!
Nutrition
Postcards
Take a Quiz
Rate My Photo

new
European Travel
Action Movies
Bible Basics
Houseplants
Romance Movies
Creativity
Family Travel


dailyclick
All times in EST

Full Schedule
g
g ASP Site

BellaOnline's ASP Editor

g

Sending Mail with ASP


One of the most common functional uses of ASP is to use it to send email messages. It can send a thank-you after a contest entry is made, send details of an order, send reminders of upcoming events, send out newsletters weekly, and much, much more.

Sending mail is extremely easy with ASP and CDONTS, which comes for free with just about any IIS installation out there. You start out with some basic variables, ToEmail, FromEmail, and Subject. You can probably guess what those three are for :) So you start out with:

FromEmail = "webmaster@aspisfun.com"
ToEmail = "destination@aspisfun.com"
Subject = "Here is your order confirmation"

Note that normally you'd probably get the ToEmail value from a form or other user input. Now, on to the mail message. You just create a long text string, with carriage returns after every line. In ASP, you can use CHR(13) for a carriage return. So you could do:

EmailMessage = "Thank you for order!" & CHR(13) & _
"Here are the details of your order." & CHR(13) & _
"...details..." & CHR(13) & _
"...details..." & CHR(13)

OK, now time to send. You can also set the importance if you wish, which most email packages show as a little exclamation mark by a high priority message or a down arrow by a low priority one.

Impt = 1

You're ready to send! Now it's only four quick statements to get the mail to send out.

Dim objMail
set objMail = CreateObject("CDONTS.NewMail")
objMail.Send FromEmail,ToEmail,Subject,EmailMessage,Impt
set objMail = Nothing

And you're set! You can now stick this code in a loop, and loop through all names in a database, or you can hook it into a form, and send mail to whoever filled in a form.

Sending HTML Mail with ASP
Error - ActiveX component can't create object: 'CDONTS.NewMail'

Introduction to ASP Ebook

Download this ebook to get everything you need to know about learning ASP - from a step by step tutorial to function lists, sample code, common errors and solutions, and much more! 101 pages.
Add Sending+Mail+with+ASP to Twitter Add Sending+Mail+with+ASP to Facebook Add Sending+Mail+with+ASP to MySpace Add Sending+Mail+with+ASP to Del.icio.us Digg Sending+Mail+with+ASP Add Sending+Mail+with+ASP to Yahoo My Web Add Sending+Mail+with+ASP to Google Bookmarks Add Sending+Mail+with+ASP to Stumbleupon Add Sending+Mail+with+ASP to Reddit




RSS | Related Articles | Editor's Picks Articles | Top Ten Articles | Previous Features | Site Map


For FREE email updates, subscribe to the ASP Newsletter


Past Issues


print
Printer Friendly
bookmark
Bookmark
tell friend
Tell a Friend
forum
Forum
email
Email Editor


Content copyright © 2014 by Lisa Shea. All rights reserved.
This content was written by Lisa Shea. If you wish to use this content in any manner, you need written permission. Contact Lisa Shea for details.

g


g features
Archives | Site Map

forum
Forum
email
Contact

Past Issues
memberscenter


vote
Poetry
Daily
Weekly
Monthly
Less than Monthly



BellaOnline on Facebook
g


| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2014 Minerva WebWorks LLC. All rights reserved.


BellaOnline Editor