0

I am trying to get Public folders email from my outlook mailbox. Presently, I can get the mails from the folders in my root folder. I use the following code for the same:

      Folder rootfolder = Folder.Bind(exchange, WellKnownFolderName.MsgFolderRoot);

      //Folder rootfolder = Folder.Bind(exchange, WellKnownFolderName.PublicFoldersRoot); // gives error                 


      rootfolder.Load();
      foreach (Folder folder in rootfolder.FindFolders(new FolderView(100)))
       {
           Console.WriteLine(folder.DisplayName);
       }

When I replace WellKnownFolderName.MsgFolderRoot with WellKnownFolderName.PublicFoldersRoot, I get the error "There are no public folder servers available." I also referred to @Mimi Gentz solution from here, but I still get the error.

Am I missing something in my code ? Please help.

Kanu Priya
  • 77
  • 1
  • 8

2 Answers2

1

You need to start by adding in the correct routing headers https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-route-public-folder-hierarchy-requests . The other thing is that by default there won't be public folders OnPrem or Office365 so an administrator would have to have setup them up first.

Glen Scales
  • 20,495
  • 1
  • 20
  • 23
  • But I can see the Public Folders in my mailbox. It should means that either Public Folders should be OnPrem or Office365. – Kanu Priya Apr 12 '19 at 05:44
  • The public folders are set for OnPrem. – Kanu Priya Apr 12 '19 at 07:59
  • Will I be able to access the public folders through EWS, if mailbox is on Office365 whereas public folders are OnPrem? I am guessing, I won't be able to do so, which is why I am getting the error. – Kanu Priya Apr 12 '19 at 12:20
0

My email is on Office365 whereas public folders are OnPrem, which is why I get no public folder servers error.

Kanu Priya
  • 77
  • 1
  • 8