Sending email with CDO is a simple task. First we create a reference to the CDO component
Set objMessage = CreateObject("CDO.Message")
then fill-in Sender, Subject and Recipient (To) fields of the headers and the body text which can be either plain text or HTML. You can also add a file attachment. You then use the Send method to send the email.
Below I'll show all three types of emails, and how to send an email using a remote SMTP server in the event you are not running your own. I've added and example to illustrate how to request a return receipt and delivery status notifications.
Please note, when using the AddAttachment method in your scripts you must use a fully qualified pathname as the argument to the method. Using just a file name or a relative path will produce the error The specified protocol is unknown.
If you receive an error message related to objMessage.From then you should try replacing it with objMessage.Sender
I've added sample code to illustrate how to load the body of the email from a text file on your disk.
I've added a sample of how to load recipient data from a database.
I've added a sample illustrating how to use data from Excel in an email.
If you are looking for an ASP based email form processor then please look here.
If you are interested in a mass mailer using CDO and VBScript, look here.
your support and keep the content updated and fresh.
|