Creating a Message

Creating a Message

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

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.

Send us your feedback about the Microsoft Exchange Server 2003 SDK.

Build: June 2007 (2007.618.1)

© 2003-2006 Microsoft Corporation. All rights reserved. Terms of use.