title: How can I find "People's Contacts" folders via Outlook's object model?
body: <p>I have some code that locates all the contact folders that a user has access to by iterating through the <code>Application.Session.Stores</code> collection.</p>
  
  <p>This works for the user's contacts and also all the public contacts folders. It also finds all the contacts folders in additional mailbox accounts that the user has added via the Tools -> Account Settings... menu command.</p>
  
  <p>However, this requires the user to have full access to the other person's account. When a user only has access to another person's contacts, then that person's contacts show up under the "People's Contacts" group in the Contacts view. How do I find those contact folders that don't show up under <code>Session.Stores</code>?</p>
  
  <p>In order to see the other user's contacts folder without adding access to their full mailbox, click File -> Open -> Other User's Folder... from the Outlook menu. In the dialog box, enter the other user's name and select <code>Contacts</code> from the Folder type drop down list.</p>
  
  <p>Here's the code (minus the error checking and logging) I'm using to find a list of all the user's Outlook contact folders. I know this can (and maybe should) be done using early binding to the <code>Outlook.Application</code> type, but that doesn't affect the results. <code>EnumerateFolders</code> is recursive so that it searches all sub folders.</p>
  
  <pre><code>Dim folderList = New Dictionary(Of String, String)
  Dim outlookApp = CreateObject(Class:="Outlook.Application")
  For Each store As Object In outlookApp.Session.Stores
      EnumerateFolders(folderList, store.GetRootFolder)
  Next
  
  Private Sub EnumerateFolders(ByRef folderList As Dictionary(Of String, String), ByVal folder As Object)
      Try
          If folder.DefaultItemType = 2 Then
              folderList.Add(folder.EntryID, folder.FolderPath.Substring(2))
          End If
  
          For Each subFolder As Object In folder.Folders
              EnumerateFolders(folderList, subFolder)
          Next
      Catch ex As Exception
  
      End Try
  End Sub
  </code></pre>