HOWTO: Use CDO to Programmatically Resolve Ambiguous Recipients

ID: Q194070


The information in this article applies to:
  • Collaboration Data Objects (CDO), versions 1.0a, 1.1, 1.2, 1.21


SUMMARY

When Resolving the Name of a Recipient to an alias of a user (for example, JohnDoe), if there is another valid alias (JohnDoeman, for instance) that is a superset of the first alias, the Resolve method yields an Ambiguous Name Resolution (ANR) dialog box.

This article addresses how to programmatically handle this scenario.


MORE INFORMATION

The following Visual Basic code sample demonstrates how to resolve an ambiguous recipient given a known exact alias of the desired recipient. This process works by using the "=" operator preceding the e-mail alias:


   Sub Main()
     'This code sample depends on a local reference to the Collaboration
     'Data Objects Library (Cdo.dll), version 1.1 or greater.
     '
     Dim objSession As MAPI.Session
     Dim objMessage As Message
     Dim objRecip As Recipient

     'Create a Session and Logon.
     Set objSession = CreateObject("mapi.session")
     objSession.Logon

     'Create the Message and add the Recipient.
     Set objMessage = objSession.Outbox.Messages.Add
     Set objRecip = objMessage.Recipients.Add
     objRecip.Name = "=JohnDoe" 'Enter desired alias w/preceeding "="
     objRecip.Resolve

     'Set the remainder of the Message Properties and Send.
     objMessage.Subject = "Subject:" & Now
     objMessage.Text = "This is the message text."
     objMessage.Send

     'Exit
     objSession.LOGOFF

    End Sub 


REFERENCES

For more detailed specifics on the MAPI internals of how Ambiguous Name Resolution works, please see the following topics in the Microsoft Developer Network:

  • Implementing Name Resolution


For additional information, please see the following article in the Microsoft Knowledge Base:
Q171440 Where to Acquire Collaboration Data Objects Libraries

Additional query words: kbCDO kbCDO100a kbCDO110 kbCDO120 kbCDO121 kbMsg kbOLE

Keywords : kbCDO100a kbCDO110 kbCDO120 kbCDO121 kbMsg kbVBp kbGrpMsg
Version : WINDOWS:1.0a,1.1,1.2,1.21
Platform : WINDOWS
Issue type : kbhowto


Last Reviewed: November 4, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.