Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Outlook: How to access other contact folders?

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!

like image 851
Alex Avatar asked Dec 03 '25 06:12

Alex


1 Answers

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.

like image 176
RobotBlogg Avatar answered Dec 05 '25 23:12

RobotBlogg