Microsoft KB Archive/260656

= How To Resolve Ambiguous Names with the Outlook Object Model Using Visual Basic =

Article ID: 260656

Article Last Modified on 7/1/2004

-

APPLIES TO


 * Microsoft Outlook 2000 Standard Edition
 * Microsoft Outlook 98 Standard Edition
 * Microsoft Visual Basic 6.0 Professional Edition

-



This article was previously published under Q260656



SUMMARY
This article demonstrates how to programmatically handle duplicate names that cause ambiguous name resolution when you use the Outlook Object Model (OOM).



MORE INFORMATION
To resolve duplicate names programmatically, you must have another method of identifying each recipient (other than the recipient's name).

The following sample subroutine uses each recipient's e-mail address to confirm the selection of the duplicate recipients. You can also use any other information that you have for each recipient if the data corresponds with the properties that are provided in the OOM. Sub AmbiguousNameRes Dim spOutlook As Outlook.Application Dim spNameSpace As Outlook.NameSpace Dim spRecipient As Recipient Dim spAdrLsts As AddressLists Dim spAdrLst As AddressList Dim spAdrEnts As AddressEntries Dim spAdrEnt As AddressEntry ' Ambiguous name resolution technique. Set spOutlook = CreateObject(&quot;Outlook.Application&quot;) Set spNameSpace = spOutlook.GetNamespace(&quot;MAPI&quot;) Set spRecipient = spNameSpace.CreateRecipient(&quot;Recipient Name&quot;)

spRecipient.Resolve

If spRecipient.Resolved = False Then ' Failed due to 0 or >1 matches. Set spAdrLsts = spNameSpace.AddressLists For Each spAdrLst In spAdrLsts Set spAdrEnts = spAdrLst.AddressEntries For Each spAdrEnt In spAdrEnts If spAdrEnt.Name = spRecipient.Name Then ' Determine if correct name. If spAdrEnt.Address = &quot;Recipient@EmailAddress&quot; Then Set spRecipient.AddressEntry = spAdrEnt spRecipient.Resolve If spRecipient.Resolved = True Then ' You have a valid recipient object. ' Send mail using this recipient. Else ' Try other properties to identify correct one? End If              End If            End If         Next Next Set spAdrEnts = Nothing End If  Set spAdrLsts = Nothing Set spNameSpace = Nothing Set spOutlook = Nothing End Sub

Keywords: kbhowto kboutlookobj kbmsg KB260656

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.