Question : VBA-"Recipients.Add" - Seperate people, Same name

Is it possible to get Recipients.Add to resolve a contact when there are two contacts with the same name. This is going to be used to build a Distribution List on existing entries within your contact list.

Duplicating the problem...

3 contacts in your contacts list (All with extra details such as home address and such)

John Smith - [email protected]
John Smith - [email protected]
Jane Smith - [email protected]

---------------------

When you do a recipients.add on "Jane smith"... it pulls up the above contact as well as the associated information. GREAT

When you try to do a recipients.add on "John Smith", it doesnt work as there are duplicated entries.
When you try to do a recipients.add on "[email protected]"... it adds a contact with [email protected] as the name and the email address, and doesnt pull up the associated information of the 1st John Smith (like fullname, home address, occupation etc)

When you try to do a recipients.add on "John Smith "... it adds an entry to the distro list, with John Smith as the name, the correct email address as well, but its not retrieving the associated information again.

---------------------

If this is better placed in a different forum, let me know... and if you require a better explanation.. just ask

===============

Here's some sample code (I have commented out some lines as they are related to the above attempts... but need to be tested seperately)

Sub x()
    Dim oApplication As New Outlook.Application
    Dim oDistro As Outlook.DistListItem
    Dim oMail As Outlook.MailItem
    Dim oRecipients As Outlook.Recipients
    Dim oRecipient As Outlook.Recipient
   
    Set oApplication = CreateObject("Outlook.Application")
    Set oDistro = oApplication.CreateItem(olDistributionListItem)
   
   
    Set oMail = oApplication.CreateItem(olMailItem)
    Set oRecipients = oMail.Recipients

    Set oRecipient = oMail.Recipients.Add("Jane Smith")
    oRecipient.Resolve

    'Set oRecipient = oMail.Recipients.Add("John Smith")
    'oRecipient.Resolve

    'Set oRecipient = oMail.Recipients.Add("johnboy@gmail.com")
    'oRecipient.Resolve

    Set oRecipient = oMail.Recipients.Add("John Smith ")
    oRecipient.Resolve

   
    oDistro.AddMembers oRecipients
    oDistro.Display
End Sub

Answer : VBA-"Recipients.Add" - Seperate people, Same name

Have a look at these two items.  The first is a Microsoft KB article that talks about ambiguous name resolution and includes a link, unfortunately a broken link, to an article that might have helped.  The second link is to a sample chapter from an MS Press book that includes a CDO code sample for handling ambiguous names.

http://support.microsoft.com/kb/321181/en-us
http://www.microsoft.com/mspress/books/sampchap/3449a.asp
Random Solutions  
 
programming4us programming4us