| Platform SDK: CDO for Windows 2000 |
You can easily reply to a message using the IMessage.Reply or IMessage.ReplyAll methods. These methods mimic the operations used in e-mail programs such as Microsoft® OutlookŪ.
Both methods return a new Message object reference. The difference between 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, as in the following 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 the same way the Reply method does, but retains any recipients in the appropriate To or CC properties.
' Reference to Microsoft ActiveX Data Objects 2.5 Library
' Reference to Microsoft CDO for Windows 2000 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)
' User wants 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
#import "c:\program files\common files\system\ado\msado15.dll" no_namespace
#import <cdosys.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();
Const g_bDebug = True
Dim iDropDir
Dim iMsgs
Dim iMsg
Dim iMsg2
Dim iConf
Dim Flds
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
Flds(cdoUseMessageResponseText) = True
' Get Language code for the user. Here we set "en-us"
' for US English. This code affects the language
' of the response text.
Flds(cdoLanguageCode) = "en-us"
Flds.Update
Set iDropDir = CreateObject("CDO.DropDirectory")
Set iMsgs = iDropDir.GetMessages("c:\Inetpub\mailroot\Drop")
If iMsgs.Count > 0 Then
' User views message 1
Set iMsg = iMsgs(1)
' Display message here
' Did author request an MDN?
If iMsg.MDNRequested Then
' Ask user whether to send the MDN
End If
' Say the user then wants to respond to this message
' Post a Reply
Set iMsg2 = iMsg.PostReply
Set iMsg2.Configuration = iConf
iMsg2.TextBody = "I agree...please proceed." & vbCrLf & iMsg2.TextBody
' ...
If g_bDebug Then
MsgBox iMsg2.GetStream.ReadText
Else
iMsg2.Post
End If
' Reply using SMTP to all recipients
Set iMsg2 = iMsg.ReplyAll
Set iMsg2.Configuration = iConf
iMsg2.TextBody = "I agree...please proceed." & vbCrLf & iMsg2.TextBody
If g_bDebug Then
MsgBox iMsg2.GetStream.ReadText
Else
iMsg2.Send
End If
End If
http://schemas.microsoft.com/cdo/configuration/usemessageresponsetext