Create calendar event in Office 365 group using EWS

As Office 365 Group (Unified Group) is robustly becoming the base service for many of Office 365 features (i.e. Planner, MS Teams, etc..) managing planner team meetings and users appointment in group calendar is inevitable now. In this post, I am going to share .net based C# code to create meeting in Office 365 Group using Managed Exchange Web Services Api (EWS).

Before proceed, you have to download Microsoft Exchange Web Services Managed API 2.0 dll and add as reference in your C# project.

ExchangeService exchService = new ExchangeService(ExchangeVersion.Exchange2013_SP1); 
exchService.UseDefaultCredentials = false; 
exchService.Credentials = new NetworkCredential("[email protected]", "pwd"); 
exchService.Url = new Uri("https://outlook.office365.com/Ews/Exchange.asmx"); 
exchService.PreAuthenticate = false; 
  
Appointment appointment = new Appointment(exchService); 
// Set the properties on the appointment object to create the appointment. 
appointment.Subject = "Sales Meeting"; 
appointment.Body = "Focus on pre-sale and marketing."; 
appointment.Start = DateTime.Now.AddDays(2); 
appointment.End = DateTime.Now.AddDays(2).AddHours(3); 
appointment.Location = "Room 111"; 
appointment.ReminderMinutesBeforeStart = 240; 
appointment.RequiredAttendees.Add("[email protected]"); 
appointment.RequiredAttendees.Add("[email protected]"); 
// Bind the specified group calendar folder. 
Folder calendar_Folder = Folder.Bind(exchService, new FolderId(WellKnownFolderName.Calendar, "[email protected]")); 
appointment.Save(calendar_Folder.Id, SendInvitationsMode.SendToNone);

The parameter SendInvitationsMode specifies how meeting invitations to be send to its attendees. It includes following options:

  • SendToNone : Do not send meeting invitations.
  • SendOnlyToAll : Send meeting invitations to all attendees but do not save a copy of the meeting invitation in the organizer’s Sent Items folder.
  • SendToAllAndSaveCopy ” Send meeting invitations to all attendees and save a copy of the meeting invitation in the organizer’s Sent Items folder.

Note: AFAIK, using Exchange Web Service (EWS) we can create only meeting not appointment in office 365 group.


Advertisement

1 thought on “Create calendar event in Office 365 group using EWS”

Leave a Comment