0

I want to be able to access the auto-complete address list that appears when typing into either the TO,CC or BCC lines within an email. I wish to be able to extract this data similarly to how I access other address lists within Outlook.

Would anyone be able to confirm if this is possible and if so how I could go about doing it.

This is currently how I'm extracting email addresses various other address lists.

foreach (Outlook.AddressEntry item in addressList.AddressEntries)
    {
        using (item.ComDisposable())
           {
               switch (item.AddressEntryUserType)
                   {
                       case Outlook.OlAddressEntryUserType.olExchangeUserAddressEntry:
                       case Outlook.OlAddressEntryUserType.olExchangeRemoteUserAddressEntry:
                           var exUser = item.GetExchangeUser();
                           Debug.WriteLine(exUser.PrimarySmtpAddress, "_GetOutlookContacts");
                           yield return new EGContact(exUser.Name, exUser.PrimarySmtpAddress, item.ID);
                           break;

                       case Outlook.OlAddressEntryUserType.olOutlookContactAddressEntry:
                            var contact = item.GetContact();
                            yield return new EGContact(contact.FullName, contact.Email1Address, item.ID);
                            break;

                       case Outlook.OlAddressEntryUserType.olExchangeDistributionListAddressEntry:
                       break;

                       default:
                       break;

                  }
          }
    }
benbants
  • 590
  • 7
  • 30
  • 1
    I thik this might be helpful: 1 - [Information about the Outlook AutoComplete list](https://support.microsoft.com/en-us/help/2199226); 2 - [Implementing Outlook email send to Autocomplete in a windows form](https://stackoverflow.com/questions/11522296/implementing-outlook-email-send-to-autocomplete-in-a-windows-form) and 3 - [autocomplete source from Outlook address book](https://stackoverflow.com/questions/9198818/autocomplete-source-from-outlook-address-book) – Maciej Los Jul 11 '17 at 13:19
  • @MaciejLos thank you for your comment, the 3rd looked promising but seems to be more orientated about creating an auto-complete source whereas I want to extract contacts from Outlooks auto-complete list. – benbants Jul 11 '17 at 13:35

2 Answers2

2

Autocomplete stream is stored as a hidden (associated) message with the message class of "IPM.Configuration.Autocomplete" in the Inbox folder. You can see the data in OutlookSpy (I am its author): go to the Inbox folder, click IMAPIFolder button on the OutlookSpy ribbon, go to the "Associated Contents" tab, locate a message with PR_MESSAGE_CLASS == "IPM.Configuration.Autocomplete", select the PR_ROAMING_BINARYSTREAM property to see its contents.

You can open that message using the Outlook Object Model (MAPIFolder.GetStorage("IPM.Configuration.Autocomplete", OlStorageIdentifierType.olIdentifyByMessageClass), read the property using PropertyAccessor.GetProperty, then parse it. Note that large autocomplete streams cannot be opened using PropertyAccessor.

If using Redemption an option (I am also its author), it exposes autocomplete as the RDONicknames collection:

 set Session = CreateObject("Redemption.RDOSession")
 Session.MAPIOBJECT = Application.Session.MAPIOBJECT
 set Nicknames = Session.GetNicknames
 for each NickName in NickNames
     Debug.Print NickName.Name & " - " & NickName.SmtpAddress
 next
Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78
  • 1
    You answered this question 4+ years before I asked! You always deliver :) You can guess what I'll be using Redemption for today – ezG Sep 10 '21 at 09:49
1

In an earlier version of Outlook, this information was stored in local .NK2 files. In Outlook 2010 and up, this information is stored in your mailbox (AutoComplete Stream). See Clearing AutoComplete and other Recipient Caches for more information.

You can use the Recipients collection (see the corresponding property of the MailItem class) for accessing the data entered to the To, Cc or Bcc fields.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45