How to Get Really Available Numbers from Exchange EWS

and sorry for the poor title of the question

I am trying to get all available rooms (not reserved) from my exchange server. The fact is that I also get the numbers that I ordered, but no one accepted .

I would like to remove them from the list after I reserve the room.

This is the code that I use to reserve the number

ExchangeService service;
//...code to new-up and config service

var request = new Appointment(service)
{
  Subject = booking.Subject,
  Start = booking.Start,
  End = booking.End,
  Location = booking.Room
};

request.RequiredAttendees.Add(booking.Person);
request.RequiredAttendees.Add(booking.Room);

request.Save(SendInvitationsMode.SendOnlyToAll);

Note that I tried to call request.Accept () right after Save (), but without this "real reservation" of the room. Pressing accept in Outlook is the only "fix." Needless to say, I tried everything I could find on this issue (I do not regularly work with Exchange).

And then the code will get free rooms

var rooms = service.GetRooms(locationAddress);

// all the meeting rooms at location
var rooms= rooms.Select(i => new AttendeeInfo { SmtpAddress = i.Address, AttendeeType = MeetingAttendeeType.Room });

// Get all availabilites from all rooms at given locations
var availability = service.GetUserAvailability(rooms, timeframe, AvailabilityData.FreeBusy);

foreach (var a in availability.AttendeesAvailability)
{
  // Here we always get all the free rooms
  // including the ones we booked earlier
  // UNTIL somebody clicks accept in Outlook and then it does not appear here!?
}

, -, Outlook, , .

, , //, , , .

Edit

, AvailabilityData. GetUserAvailability ( FreeBusy, FreeBusyAndSuggestions , !)

+4
1

, ... ( ) , (). ...

  var busyRoomToRemove = a.CalendarEvents.ToList().Find(x => x.FreeBusyStatus == LegacyFreeBusyStatus.Busy);
  a.CalendarEvents.Remove(busyRoomToRemove); 

:-)

+1

Source: https://habr.com/ru/post/1626505/


All Articles