I am using EWS 2.0 to access a users calendar in Office 365. I use AutoDiscover to find the ExchagneService, then bind to the calendar via CalendarFolder.Bind and at the next statement folder.FindAppointments I get the error
An internal server error occurred. The operation failed.
I know that the credentials used to access the user are correct - have tested in the webmail and it works just fine.
If I use my own credentials (after having assigned rights to the user in question) my program does not fail. Only apparent difference is the administrator role.
Below I have listed the central parts of the code:
First the AutoDiscover (which work)
service = new ExchangeService(ExchangeVersion.Exchange2010_SP1,TimeZoneInfo.Local ); // service is a global variable
service.Credentials = new NetworkCredential(ConfigClass.CalendarReaderName, ConfigClass.CalendarReaderPassword);
service.AutodiscoverUrl(cal, RedirectionUrlValidationCallback);
Then the part where I want to get the appointments
CalendarView view = new CalendarView(_firstdate, _lastdate);
Mailbox mailbox = new Mailbox(cal); // cal is the e-mail address of the user
FolderId id = new FolderId(WellKnownFolderName.Calendar, mailbox);
CalendarFolder folder = CalendarFolder.Bind(service, id);
FindItemsResults<Appointment> findResults = folder.FindAppointments(view); // This is where the error occurs
Anybody know what this error actually means and how to solve the situation. I want to run the program using a service account rather than my personal credentials.