Search code examples
c#exchangewebservicespublic-folders

EWS Exception: There are no public folder servers available


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.


Solution

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