3

Some people have a number of lists/folders in Outlook, under Contacts (e.g. besides Contacts and Suggested Contacts, people can add new "folders" of contacts).

Now, my questions:

  1. How can I get a list of all these lists/folders?
  2. How can I access all the contacts in any of these folders?

I know that if I want to access the contacts from the main "Contacts" list, then the code looks like this:

   MAPIFolder oMAPIFolder = 
              oNmSpc.GetDefaultFolder(OlDefaultFolders.olFolderContacts);
   oItemsTemp = oMAPIFolder.Items;

How would it look like when accessing other contact lists/folders?

Thanks!

zs2020
  • 53,766
  • 29
  • 154
  • 219
Alex
  • 7,432
  • 20
  • 75
  • 118

1 Answers1

1

To access the "Suggested Contacts" Folder proceed exactly as you do for contact but

Instead of

outlook := CreateOLEObject('Outlook.Application');
  NameSpace := outlook.GetNameSpace('MAPI');
  ContactsRoot := NameSpace.GetDefaultFolder(olFolderContacts) ;

Use

outlook := CreateOLEObject('Outlook.Application');
  NameSpace := outlook.GetNameSpace('MAPI');
  SuggestedContactsRoot := NameSpace.GetDefaultFolder(olFolderSuggestedContacts);

Where olFolderSuggestedContacts has a value of 30 (decimal) or $0000001E in Hexadecimal

I know this is Delphi language, but adapatation to C# should be straightforward.

zdrsh
  • 1,667
  • 1
  • 14
  • 26
RobotBlogg
  • 26
  • 1