HOWTO: Use CDO to Set Up Reply to Alternate RecipientLast reviewed: February 20, 1998Article ID: Q181408 |
The information in this article applies to:
SUMMARYThis article describes and gives sample code on how to use CDO to set an alternate "Reply To" recipient of a message. This functionality, when enabled on a message, automatically populates the Recipients collection of the message with a recipient other than the original sender (which is the default) when the user selects "Reply".
MORE INFORMATION
Sample Code
' The following Visual Basic code sample assumes the a reference ' has been made to the CDO library. ' Option Explicit Dim objSession As MAPI.Session Dim objMsg As Message Dim objAltRecip As Recipient Dim g_bstrReplyToID As Variant Dim g_bstrReplyToName As String Dim bstrFlatEntry As Variant Dim bstrBlob As Variant Private Sub Form_Load() Set objSession = CreateObject("MAPI.Session") objSession.Logon "My Profile Name" 'Create Message and add a Recipient. Set objMsg = objSession.Outbox.Messages.Add( _ Subject:="This is the subject line", _ Text:="This is the body of the message") objMsg.Recipients.Add Name:="NameOfMyMsgRecipient" objMsg.Recipients.Resolve 'Enable the Alternate Recipient functionality '-------------------------------------------- ' 1. Get an AddrEntry for the Alternate Recipient. Set objAltRecip = objMsg.Recipients.Add(Name:="NameOfMyMsgAltRecip") objAltRecip.Resolve ' 2. Assign the ID and Name to variables for subsequent use. g_bstrReplyToID = objAltRecip.ID g_bstrReplyToName = objAltRecip.Name ' 3. Remove the Alternate Recipient from the Recipient list (if ' applicable). objAltRecip.Delete ' 4. Hash the ID into BSTR that looks like a FLATENTRYLIST structure. FlatLength = CStr(Hex(Len(g_bstrReplyToID) / 2)) bstrFlatEntry = FlatLength & "000000" & g_bstrReplyToID StructLength = Hex(Len(bstrFlatEntry) / 2) bstrBlob = "01000000" & StructLength & "000000" & bstrFlatEntry objMsg.Fields.Add CdoPR_REPLY_RECIPIENT_NAMES, g_bstrReplyToName objMsg.Fields.Add CdoPR_REPLY_RECIPIENT_ENTRIES, bstrBlob 'Send the Message. objMsg.Send End Sub REFERENCESFor additional information, please see the following article(s) in the Microsoft Knowledge Base:
ARTICLE-ID: Q171440 TITLE : Where to Acquire the Active Messaging Libraries ARTICLE-ID: Q176916 TITLE : INFO: Active Messaging and Collaboration Data Objects ARTICLE-ID: Q174211 TITLE : HOWTO: Access Message Property Not Exposed by Active MessagingFor additional information on the FLATENTRYLIST structure or "Collaboration Data Objects", please see the Microsoft Developer Network (MSDN) Library.
|
Additional query words: ActMsg
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |