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:
Post a Comment