Search code examples
exchangewebservicesews-managed-api

Getting error when try to create meeting on exchange calendar through exchange api


I am using EWS Managed exchange api in c# I am getting below error when i am try to create meeting on default calendar (Calendar).

Cannot create a calendar item in a non-calendar folder.

here is my code :

Appointment appointment = new Appointment(service);

appointment.Subject = "Test meeting";

appointment.Body = "Test Connection meeting";

appointment.Start = meetingStartTime;

appointment.End = meetingEndTime;

appointment.Sensitivity = Sensitivity.Normal;

            appointment.Save(calendarId, SendInvitationsMode.SendToNone);

Note : I am fetching the calendar by calendar name. As below

SearchFilter sfSearchFilter = new SearchFilter.IsEqualTo(FolderSchema.DisplayName, "Calendar");

Please revert as soon as possible.


Solution

  • Most certainly the error is where you fetch the SearchResult.

    A workaround would be to just call

    appointment.Save(WellKnownFolderName.Calendar, SendInvitationsMode.SendToNone);
    

    This calls for the default calendar folder without the need to search it first.