This documentation is archived and is not being maintained.
Creating a Message
EWS Managed API
Topic Last Modified: 2006-06-12
To build a new message, you must first create an instance of the Message Component Object Model (COM) class, as shown in the following example:
Visual Basic
' Reference to Microsoft ActiveX Data Objects 2.5 Library ' Reference to Microsoft CDO for Exchange 2000 Server Library Dim iMsg as new CDO.Message
C++, IDL
#import "c:\program files\common files\system\ado\msado15.dll" no_namespace #import "c:\program files\common files\microsoft shared\cdo\cdoex.dll" no_namespace // ... MessagePtr iMsg(__uuidof(Message));
VBScript
Dim iMsg
Set iMsg = CreateObject("CDO.Message")
You can create and send or post a simple message by using only the IMessage interface.
-
To send a
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 several 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.
Show: