How do I send mail from an ASP page using CDONTS?

About CDONTS

CDONTS allows you to send mail using the standard SMTP protocol from any program that can use ActiveX/OLE components. Features include:

  1. SMTP (sending) Messages
  2. Multiple File Attachments
  3. File attachments support MIME and UUEncoding

Simple Mail Example

Using the component is as simple as

  1. Creating the object
  2. Setting a few properties
  3. Calling the Send method

The following code demonstrates how to use CDONTS from VBScript. In this example Joe from Joe’s Widgets wishes to send an email to John Smith.

Set Mailer = Server.CreateObject("CDONTS.NewMail")
NewMail.From    = "Joe@somehost.com"
NewMail.To      = "jsmith@anotherhostname.com"
NewMail.Subject = "Great SMTP Product!"
NewMail.Body    = "Dear Stephen" & VbCrLf & "Your widgets order has been processed!"
if NewMail.Send then
  Response.Write "Mail sent..."
else
  Response.Write "Mail send failure. Error was " & Mailer.Response
end if

By testing the result of the Send method we can determine if the mailing process was successful or not.

  • 21 Users Found This Useful
Was this answer helpful?

Related Articles

Where can I find documentation for ServerObject's AspMail component?

This documentation can be found at: http://www.serverobjects.com/products.html For...

How do I upload files through my web pages?

You can use Software Artisan's SAFileUP. This is an ASP component that allows you to upload files...

What is PageCounter and how do I use it?

About Page Counter PageCounter is an object that counts and displays the number of times a Web...

How do I setup Microsoft Outlook Express to read my e-mail?

Follow these steps: Open Microsoft Outlook Express. From the Tools menu, click...

How do I setup Netscape Messenger to read my e-mail?

Follow these steps: Open Netscape Navigator. Click the Edit menu and then click Preferences......