PRB: Changing Properties of AddressEntry object of a Recipient

ID: Q171671

The information in this article applies to:

SYMPTOMS

When attempting to change properties or fields of the AddressEntry object of a Recipient of a message, the property/field changes are not saved.

For example, using the following code, the change to the PR_SEND_RICH_INFO is not saved, as seen in the Details page that is displayed. (See the MORE INFORMATION section below for how the variables are defined.)

RESOLUTION

Follow these steps to make changes to the AddressEntry object of a recipient of a message. This code may be used to correct the complete code example provided in the MORE INFORMATION section below.

1. After resolving the recipient, create a new AddressEntry object based on

   the AddressEntry property of the Recipient:

      Dim objAddress As Mapi.AddressEntry
      Set objAddress = objRecip.AddressEntry

2. Change the properties or fields on the new AddressEntry object:

      objAddress.Fields(ActMsgPR_SEND_RICH_INFO) = False

3. Call the Update method of the new AddressEntry object:

      objAddress.Update

4. Set the AddressEntry property of the Recipient object to the
   AddressEntry object created in step 1 above:

      objRecip.AddressEntry = objAddress

MORE INFORMATION

Steps to Reproduce Behavior

The following code placed in a Visual Basic module will reproduce the problem described in the Symptoms section above. Note that the property change used here for illustration purposes assumes that the default setting of the PR_SEND_RICH_INFO property is True. If the default setting on your system is False, you will want to modify the code below to see the behavior.

' Note that you should have "Microsoft Active Messaging 1.1 Object
    ' Library" marked as a reference for your project in order for this
    ' code to function.
    Dim objSession As Session
    Dim objMessage As Mapi.Message
    Dim objRecip As Mapi.Recipient
    Dim objAddress As Mapi.AddressEntry

    ' Create and logon to a MAPI Session
    Set objSession = CreateObject("Mapi.Session")
    objSession.Logon ShowDialog:=True

    ' Create a new message
    Set objMessage = objSession.Outbox.Messages.Add

    ' Create a new recipient on our message
    Set objRecip = objMessage.Recipients.Add
    ' Set the properties of our recipient and resolve to a single address
    objRecip.Name = "myemail@mycompany.com"
    objRecip.Type = ActMsgTo
    objRecip.Resolve

    ' *** To make this code function as needed, replace this section
    ' *** of code with the corrected code provided in the Resolution
    ' *** section above.
    ' Attempt to set the PR_SEND_RICH_INFO property.
    ' This is the line of code that may need to change, depending on the
    ' default setting on your system.
    objRecip.AddressEntry.Fields(ActMsgPR_SEND_RICH_INFO) = False
    ' Update the AddressEntry object
    objRecip.AddressEntry.Update

    ' View the details of the Recipient to confirm changes
    objRecip.AddressEntry.Details

    ' Delete the message and Logoff the Session
    objMessage.Delete
    objSession.Logoff

REFERENCES

For additional information about Collaboration Data Objects versus Active Messaging, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q176916
   TITLE     : INFO: Active Messaging and Collaboration Data Objects (CDO)

Keywords          : kbcode kbActMsg kbCDO kbCDO110 kbCDO120 kbCDO121 kbMsg 
Version           : WINDOWS:1.1,1.2,1.21
Platform          : WINDOWS
Issue type        : kbprb

Last Reviewed: December 17, 1998