EWS Post 2 of n - Finding Folders

 | #CSharp#EWS#Exchange-Web-Services

The EWS SDK can be found here.

I suggest using Linqpad to run these code snippets as that is where they are being written. Just add a reference to C:\Program Files\Microsoft\Exchange\Web Services\2.0\Microsoft.Exchange.WebServices.dll and a using statement for Microsoft.Exchange.WebServices.Data and you’re good to go.

Part 2 of n in my EWS series, this time covering finding folders. This is a two liner, barely worthy of it’s own blog post, but it’s late and, for something so simple, there seem to be alarmingly few straight forward examples of this on the interwebs, so enjoy.

var service = new ExchangeService(ExchangeVersion.Exchange2010);
service.Credentials = new WebCredentials("myusername","mypassword");
service.Url = new Uri("https://mymailserver/ews/exchange.asmx");

var f = new FolderView(100);
var res = service.FindFolders(WellKnownFolderName.PublicFoldersRoot,f);

About Alan Parr

Photo of Alan Parr

I am a .Net developer based in the Midlands in the UK, working on Azure, .Net Framework, .Net Core, and just generally playing around with anything that interests me. I play snooker (badly), archery (acceptably) and am a recovering Windows Phone user.