programmingsite : code , tutorials and scripts
Navigation

home


ASP
ASP.net
PHP
JavaScript
C
C++
Java
Visual Basic


Resources
code
tutorials
training

Ads
Products

 

 

Sending Email with ASP





Sending Email with ASP

All good websites need to be able to send and recieve email . Ok you could have a mailto link in your page pointing to your email address which when the user clicked on it their default email client opened up but why not let ASP handle this . We will use ASP and CDONTS for this task .

CDONTS is available on the Windows NT /2000 platforms and provides the necessary objects , methods and properties to send email . You can also send attachments , send HTML mail and various other tasks .

Lets Begin :

First of all we have to create an instance of the CDONTS object , we achieve this like this

<%
Dim objCdonts
Set objCdonts = Server.CreateObject("CDONTS.NewMail")
%>

Now we add the various importantemail addresses  to the script , these include the address you are sending to , the address where the mail is from .

objCdonts.To = "youraddress@youremail.com"
objCdonts.From = "myaddress@myemail.com"

Now lets add the subject line of the email message. We do this with the following.

objCdonts.Subject = "Hello this is my sample email"

OK hopefully you are still with me , an email is no use without some message in the actual body of it , here is how we go about this .

objCdonts.Body = "Hello , I am just testing this email script out "

OK that's our email all set up and ready to go but wait we need to send it and once it is sent it always good practice to delete the instance of the CDONTS object and free up resources on your server.

objCdonts.Send
Set objCdonts = Nothing



Lets see the complete script

<%
Dim objCdonts
Set objCdonts = Server.CreateObject("CDONTS.NewMail")
objCdonts.To = "youraddress@youremail.com"
objCdonts.From = "myaddress@myemail.com"
objCdonts.Subject = "Hello this is my sample email"
objCdonts.Body = "Hello , I am just testing this email script out "
objCdonts.Send
Set objCdonts = Nothing
%>





Products
500 Java Tips E-book
PHP editor
PERL editor
Beginning Java
Beginning Visual Basic
Learn VB.net
Learn VB 6
VB and databases
ASP image library
C++ builder programming
C++ fundamentals
Asp Studio 2005
Xtra PHP
Online PHP Script Encoder
Comparison

Links
Make money selling software
Golf resource site
UK price comparison
UK shopping
free articles
free stuff
Gambling resources
Software directory
Health and fitness
Sexy free wallpapers
Hosting resources
ASP site
Beginners PHP
Anime videos
Domain names
Dating site
Programming resources
Dropshippers
Maxi directory
free recipes
Coupons and deals
iPod resources

Ads