3

I need a way to determine if an Outlook folder is public. I suspect there is some property Microsoft.Office.Interop.Outlook that will allow me to do it, but I can't find it.

Paul Sasik
  • 73,575
  • 18
  • 144
  • 180
  • Outlook folders don't seem to have a "public" properties but they do have permissions. Is that what you're after? – Paul Sasik Dec 14 '10 at 21:48
  • 2
    Public folders are an exchange thing. Not sure if the Outlook OM would let you access it. I know for sure that EWS (Exchange Web Service) allows access to public folders. – RedDeckWins Dec 16 '10 at 07:28

2 Answers2

1

If you can get at the IMsgStore interface associated with the folder in question (sorry, no idea how to do that with pure C# - I recommend Redemption) you could query the PR_MDB_PROVIDER property to see whether it is pbExchangeProviderPublicGuid.

Update based on your comment to KG's answer:

If you want to filter out the contacts that are inside your primary mailbox, just compare their StoreID with that of your default inbox folder - or simply don't enumerate folders from any other stores to begin with.

Oliver Giesen
  • 8,745
  • 5
  • 43
  • 81
0

What you want is Exchange Web Service, specifically the FindFolder operation (see here or here for some MSDN descriptions).

Although, from the looks of it, there is no specific property that identifies whether or not the folder is "public", like @RedDeckWins mentions.

UPDATE

If you are not specifically required to use managed C# for this, you can use the Powershell Exchange Cmdlets (check this out here). Specifically, this command might be helpful:

Get-PublicFolder -Recurse | Format-List Name

Powershell is pretty easy to use by itself, but it can also be called from C#, if the server your code is running on has it installed (which, for most modern boxes, should).

If you ARE limited to C#, take a look at this StackOverflow question: List of email address to public folders in exchange

Community
  • 1
  • 1
karlgrz
  • 13,425
  • 10
  • 43
  • 57
  • I want to enumerate the folders and pull out the contacts, but just the local ones, not the contacts on the exchange server. It seems odd that I can't find a good way to determine if the contacts are local or remote on the exchange server when I enumerate through them. – Greg Coleson Feb 10 '11 at 16:47
  • See my update. Are you limited to ONLY C#, or can you use Powershell? The tools included with Exchange might help here greatly. – karlgrz Feb 10 '11 at 17:02
  • @Greg: See the update to my answer: If you only want the Contacts folders inside your primary mailbox (*not* the Public ones), just compare their `StoreID`s or simply limit your search to the local store. – Oliver Giesen Jun 06 '11 at 11:32