|
All Scripts JavaScripts ASP Scripts Other Scripts
Send
basic email using CDONTS
I spent a long time searching on the Internet trying to figure out how to send email using CDONTS. I was able to find different peaces of information on different Web Sites. I want to summarize everything that I found.
This page shows how to send simple mail as soon as page loads. If you want to see how to customize and send dynamic email click here. To see tips and tricks how to customize email click here. To see how to send email to multiple users that have to be picked up from the RecordSet click here.
First thing to do is to open mail session and declare mail variable:
dim MailObj
set MailObj = Server.CreateObject("CDONTS.NewMail") |
Then:
|
Code: |
From : |
MailObj.From = "from@yourdomain.com" |
To: |
MailObj.To = "anyone@yourdomain.com" |
Cc: |
MailObj.Cc = "anyone@yourdomain.com" |
Bcc |
MailObj.Bcc = "anyone@yourdomain.com" |
Subject: |
MailObj.Subject = "Here is the subject" |
Body: |
MailObj.Body = "The body of the email." |
Send email and close session:
MailObj.Send()
set MailObj = nothing |
This is the code for the page that send email as soon as it loads and it is to be is placed above <html>:
|
<%
dim MailObj
set MailObj = Server.CreateObject("CDONTS.NewMail")
MailObj.From = "from@yourdomain.com"
MailObj.To = "anyone@yourdomain.com"
MailObj.Subject = "Here is the subject"
MailObj.Body = "The body of the email."
MailObj.Send()
set MailObj = nothing
%> |
If you want to see how to customize and
send dynamic email click here.
|