Platform SDK: Exchange 2000 Server

Replying to Messages

[This is preliminary documentation and subject to change.]

You can easily reply to a message using the IMessage.Reply or IMessage.ReplyAll methods. These methods mimic the behavior used in e-mail programs such as Microsoft® Outlook.

Both methods return a new Message object reference. The difference in the two methods is that the ReplyAll method retains the original message's CC line in the new message. You must set the From property in the new message before you send the message.

If the http://schemas.microsoft.com/cdo/configuration/usemessageresponsetext field is set to True (VARIANT_TRUE), the TextBody of the reply method contains standard reply formatting. For example,

----Original Message----
From: "A Person" <person@microsoft.com>
Sent:  Sat, 23 Jan 1998 12:34:34 -0800
To:  "Another" <another@microsoft.com>
Subject: See this attached message

(body of the message here)
  

This message response text is localized into the language specified using the http://schemas.microsoft.com/cdo/configuration/languagecode field in the Configuration object.

The Reply method puts the sender of the original message in the To property of the new message but removes all other recipients and any attachments. If the message contains a ReplyTo field, the Reply method sets the IMessage.To property to this ReplyTo field; otherwise, it sets the To property to the From field.

The ReplyAll method fills in the To line and removes any attachments as does the Reply method, but retains any recipients in the appropriate To or CC properties.

[Visual Basic]
' Reference to Microsoft ActiveX Data Objects 2.5 Library
' Reference to Microsoft CDO for Exchange 2000 Server Library
' ..
Dim iMsgs as CDO.IMessages
Dim iDropDir as New CDO.DropDirectory
Dim iMsg as CDO.Message

Set iMsgs = iDropDir.GetMessages("c:\Inetpub\mailroot\Drop");
Set iMsg = iMsgs(1)

' want to reply all

Dim iMsg2 as CDO.Message
Set iMsg2 = iMsg.ReplyAll
'   or Set iMsg2 = iMsg.Reply
'      Set iMsg2 = iMsg.PostReply
' ..configure message object
'   add any other recipients
iMsg2.TextBody = "I agree...please proceed." & vbCrLf & iMsg2.TextBody
iMsg2.Send
[C++,IDL]
#import "c:\program files\common files\system\ado\msado15.dll" no_namespace
#import "c:\exchsrvr\cdoex.dll" no_namespace
// ...
IDropDirectoryPtr iDropDir(__uuidof(DropDirectory));
IMessagesPtr iMsgs;
iMessagePtr  iMsg;

iMsgs = iDropDir->GetMessages("c:\\Inetpub\\mailroot\\Drop");
iMsg  = iMsgs->Item[1];

// want to reply all

IMessagePtr iMsg2;
iMsg2 = iMsg->ReplyAll();
// iMsg2 = iMsg->Reply();
// iMsg2 = iMsg->PostReply();
//     add any other recipients
iMsg2->TextBody = "I agree...please proceed." + "\r\n" + iMsg2->TextBody;
iMsg2->Send();
[VBScript]
Dim iDropDir
Dim iMsgs
Dim iMsg

Set iDropDir = CreateObject("CDO.DropDirectory")
Set iMsgs = iDropDir.GetMessages("c:\Inetpub\mailroot\Drop")
Set iMsg = iMsgs(1)

' want to reply all

Dim iMsg2
Set iMsg2 = iMsg.ReplyAll
' or Set iMsg2 = iMsg.Reply
'    Set iMsg2 = iMsg.PostReply
' ... configure message object
'     add any other recipients
iMsg2.TextBody = "I agree...please proceed." & vbCrLf & iMsg2.TextBody
iMsg2.Send