Search code examples
c#asp.netexchange-serverexchangewebservicesexchange-server-2010

Exchange server 2010 Version support on folder search for asp.net


I am trying to sync to an exchange folders by trying to run the below command to find all the folders in asp.net c#.

view.Traversal = FolderTraversal.Deep;

        FindFoldersResults findFolderResults = service.FindFolders(new FolderId(WellKnownFolderName.Root, mailbox), view);

However this command previously worked on another mail server have failed for the current one I am using. The error returned on this line is

Microsoft.Exchange.WebServices.Data.ServiceVersionException: Exchange Server doesn't support the requested version.
   at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ProcessWebException(WebException webException)
   at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.GetEwsHttpWebResponse(IEwsHttpWebRequest request)
   at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ValidateAndEmitRequest(IEwsHttpWebRequest& request)
   at Microsoft.Exchange.WebServices.Data.SimpleServiceRequestBase.InternalExecute()
   at Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.Execute()
   at Microsoft.Exchange.WebServices.Data.ExchangeService.InternalFindFolders(IEnumerable`1 parentFolderIds, SearchFilter searchFilter, FolderView view, ServiceErrorHandling errorHandlingMode)
   at Microsoft.Exchange.WebServices.Data.ExchangeService.FindFolders(FolderId parentFolderId, FolderView view) 

The funny thing is both of exchange server are exchange 2010 so anyone have any idea what problem this really is? or exactly what is causing the command not supported.

The successful run server is version 14.03.0195.001
The failed server version is         14.00.0722.000

Is this error really caused by this Minor error? I mean both of them are exchange 2010 server really shouldn't the commands be the same?


Solution

  • Try instantiating the ExchangeService object with ExchangeVersion.Exchange2010. (There are ExchangeVersions for SP1 and SP2 also.) I don't know the 14.x.y.z numbers on each, but clearly the failing server is down-level from the working one. EWS is not complaining about the function you want, but rather about the version you're requesting. Thus if the failing server was running E2010 SP1, and your EWS DLL was defaulting to Exchange2010_SP2, things would not work. You're probably safe dropping down to RTM-flavor of E2010, unless other pieces of your code need something specific in SP1 or SP2, in which case you'll have to determine exactly what the 14.x.y.z number correspond to.