简体   繁体   中英

Outlook: How to access other contact folders?

Some people have a number of lists/folders in Outlook, under Contacts (eg 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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM