Platform SDK: CDO for Windows 2000 |
To begin building a new message, first create an instance of the Message COM class, as shown in the following example:
' Reference to Microsoft ActiveX Data Objects 2.5 Library ' Reference to Microsoft CDO for Windows 2000 Library Dim iMsg as New CDO.Message
#import "c:\program files\common files\system\ado\msado15.dll" no_namespace #import <cdosys.dll> no_namespace // ... IMessagePtr iMsg(__uuidof(Message));
Dim iMsg Set iMsg = CreateObject("CDO.Message")
You can create and send or post a simple message using only the IMessage interface. To send an Simple Mail Transfer Protocol (SMTP) message, you must at least set the To and From properties on the IMessage interface. To post an Network News Transfer Protocol (NNTP) message, you must at least set the IMessage.Newsgroups and IMessage.Subject properties.
To send or post multiple messages efficiently, create a single Message object and reuse it for each message. To send individual messages with the same content to many recipients, change the address and call the IMessage.Send or IMessage.Post method for each message. To send different content in each message, use the IBodyParts.DeleteAll method to clear all of the body parts associated with a Message object.