Wednesday, April 26, 2017

Create a meeting by using the EWS Managed API

Our team has used EWS API's Appointment service to book a meeting room. During our testing, its been  noted that  the room was not blocked on the exchange server and  over lapping meetings can be booked for that room.

I had gone through the code and found that the meeting room was added as part of the required attendees list
meeting.RequiredAttendees.Add("roomid@contoso.com");

In this case, the room  has to accept the request so as to get the calendar blocked. The MSDN document didn't give any clue to add a meeting room. It specifies a "Location" field, however it wont block the meeting room for the specified time range.

https://msdn.microsoft.com/en-us/library/office/dn495611(v=exchg.150).aspx

After a few trail and error, we found that, the meeting room must be added as part of the resources
 meeting.Location = "Location name";
meeting.Resources.Add("roomid@contoso.com");

Updated Code -  assuming an exchange service object has been created:

Appointment meeting = new Appointment(service);

// Set the properties on the meeting object to create the meeting.
meeting.Subject = "Team building exercise";
meeting.Body = "Let's learn to really work as a team and then have lunch!";
meeting.Start = DateTime.Now.AddDays(2);            
meeting.End = meeting.Start.AddHours(4);
meeting.Location = "Conference Room 12";
meeting.Resources.Add("ConferenceRoom12@contoso.com");
meeting.RequiredAttendees.Add("Mack@contoso.com");
meeting.RequiredAttendees.Add("Sadie@contoso.com");
meeting.OptionalAttendees.Add("Magdalena@contoso.com");
meeting.ReminderMinutesBeforeStart = 60;

// Save the meeting to the Calendar folder and send the meeting request.
meeting.Save(SendInvitationsMode.SendToAllAndSaveCopy);

No comments:

Featured post

How to connect to Mongo Atlas from Robo 3T

If you use a local instance of MongoDB, you might be a great fan of Robo3T. However, if you are using Mongo Atlas, the Atlas web interface p...

Popular Posts