Platform SDK: Exchange 2000 Server

Sending and Posting Messages

[This is preliminary documentation and subject to change.]

To send a message, use the IMessage.Send method. Before you can send a message, you must set at least one recipient address and one sender address. You can use the To and From properties for the Message object to do so.

To post a message, use the IMessage.Post method. Before you can post a message, you must set at least the From, Subject, and Newgroups message header fields for the object. You can use either the IMessage.From, IMessage.Subject, and IMessage.Newsgroups properties for the Message object.

The following example demonstrates these steps using IMessage interface properties and fields in the IMessage.Fields collection.

[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
' configure object here if necessary
With iMsg
   .From     = "Someone@Somewhere.microsoft.com"
   .CC       = "Another@microsoft.com"
   .Subject  = "Your lights are on, but no one is home"
   .TextBody = "You left your lights on this morning."
   .Newsgroups = "somewhere.general"
   .Post
   .Newsgroups = ""
   .To       = "SomeoneElse@Somewhere.microsoft.com"
   .Fields(cdoDispositionNotificationTo) = "Someone@somewhere.microsoft.com"
   .Fields.Update
   .Send
End With

Set iMsg = Nothing
[C++,IDL]
#import "c:\program files\common files\system\ado\msado15.dll" no_namespace
#import "c:\exchsrvr\cdoex.dll" no_namespace
// ...
IMessagePtr iMsg(__uuidof(Message));
iMsg->From     = "Someone@Somewhere.microsoft.com";
iMsg->CC       = "Another@microsoft.com";
iMsg->Subject  = "Your lights are on, but no one is home";
iMsg->TextBody = "You left your lights on this morning.";
iMsg->Newsgroups = "somewhere.general";
iMsg->Post();
iMsg->Newsgroups = "";
iMsg->To       = "SomeoneElse@Somewhere.microsoft.com";
iMsg->Fields->Item[cdoDispositionNotificationTo]->Value = _variant_t("someone@somewhere.microsoft.com");
iMsg->Fields->Update();
iMsg->Send();
iMsg = NULL;
[VBScript]
Dim iMsg
Set iMsg = CreateObject("CDO.Message")
' configure object here if necessary
With iMsg
   .From     = "Someone@Somewhere.microsoft.com"
   .CC       = "another@microsoft.com"
   .Subject  = "Your lights are on, but no one is home"
   .TextBody = "You left your lights on this morning."
   .Newsgroups = "somewhere.general"
   .Post

   .Newsgroups = ""
   .To       = "SomeoneElse@Somewhere.microsoft.com"
   .Fields(cdoDispositionNotificationTo) = "someone@somewhere.microsoft.com"
   .Fields.Update
   .Send
End With

Set iMsg = Nothing

The mechanism for sending or posting messages is controlled through configuration settings associated with the object. For more information, see Configuring the Message Object.

See Also

Configuring the Message Object