0

As I mentioned in a former Question it is no problem to get shared contacts in Outlook via MAPI. But this is only possible, if you know the Users/Recipients sharing contacts (or also calendar) with the Current Outlook User.

Now back to my question: How can I get a list of Recipients sharing their contacts with me?

With the list I would do a foreach creating the Recipients and than access the shared folder.

// Get recipients    
IList<string> recipientsSharingContacts =  **???** ;

// Import/Read shared contacts 
foreach (string recip in recipientsSharingContacts){

    // Open Shared Folder
    MAPIFolder sharedContactsFolder = 
      Application.Session.GetSharedDefaultFolder(recip, OlDefaultFolders.olFolderContacts)

    // Import Contacts 
    ...

}

Hope someone can help me out.

Community
  • 1
  • 1
Tobias
  • 2,945
  • 5
  • 41
  • 59

1 Answers1

2

If someone is interested in the solution, here is how I do it:

ContactsModule module = (ContactsModule)outlookObj.ActiveExplorer().NavigationPane.Modules.GetNavigationModule(OlNavigationModuleType.olModuleContacts);
foreach (NavigationGroup navigationGroup in module.NavigationGroups) {
     foreach (NavigationFolder navigationFolder in navigationGroup.NavigationFolders) {
          foreach (var item in navigationFolder.Folder.Items) {
                     // Found Folders are: Contacts, Suggested Contacts and Shared Contact Folders


                     // Import/Read ContactItems
                     ...
                }
Tobias
  • 2,945
  • 5
  • 41
  • 59
  • 1
    Keep in mind that you will only see the mailboxes of the users explicilty opened by the current user. It will not give you all the mailboxes that *can* be opened because the current user has the right to open their mailboxes. – Dmitry Streblechenko Nov 24 '12 at 18:12
  • this throws the following exception on outlook 2003. I have not tested 2007 yet, but I think it only works on 2010. Description: The process was terminated due to an unhandled exception. Exception Info: System.AccessViolationException Stack: at Microsoft.Office.Interop.Outlook._Explorer.get_NavigationPane() – rideon88 Jan 15 '13 at 16:46
  • This works fine in 2007 SP2. The biggest Problem with this is, that there is a need of an ActiveExplorer which can be fatal if you call it from outside outlook. – Florian Mar 26 '13 at 12:20