Kiran Paul
Kiran Paul

Reputation: 885

Find All Available Meeting Rooms using Microsoft.Office.Interop.Outlook

I was developing one application where I want to retrieve the available rooms from the "All Rooms" of the outlook address book. I am able to retrieve all the room entries from "All Rooms" Address Entry List. And then able to search for individual room's availability by calling AddressEntry.GetFreeBusy(). But the problem I am facing is the time performance of the code. If the number of rooms is high(let's say 500) then the time take to search availability of the room(worst case scenario where available room locates near to last of the list) is very high.

Microsoft.Office.Interop.Outlook.Application app = new Microsoft.Office.Interop.Outlook.Application()
var allRooms = app.Session.AddressLists["All Rooms"].Cast<Microsoft.Office.Interop.Outlook.AddressEntry>().ToLis();
DateTime today = DateTime.Today;
foreach(var room in allRooms)
{
    //the below function will return the room status in a string of 1&0 for an interval of 1 min
    string status = room.GetFreeBusy(today, 1, true); //sequentially calling this method is costly. What improvement can I do here?
    //process the status and make some if free for certain time period add to list of available list
}

Upvotes: 1

Views: 2047

Answers (2)

digitally_inspired
digitally_inspired

Reputation: 777

If you are a .Net Developer then use Microsoft Graph APIs for this purpose. I used

POST /me/calendar/getSchedule POST /users/{id|userPrincipalName}/calendar/getSchedule

from to achieve this. You can login as your userid and use ME option or you can use application mode login to login and use {id|userPrincipalName} to get calendar details for a room.

This link provides the basics on how to login and have good examples for Graph in general.

https://developer.microsoft.com/en-us/graph/graph-explorer

Ref: https://learn.microsoft.com/en-us/graph/api/calendar-getschedule?view=graph-rest-1.0&tabs=http

Upvotes: 1

Eugene Astafiev
Eugene Astafiev

Reputation: 49395

The GetFreeBusy method accepts three parameters and the default value for the MinPerChar parameter is 30 minutes. But your code only checks the first minute of the appointment. You need to go over the whole duration of your meeting (at least 30 minutes). Take a look at the similar forum thread.

Upvotes: 1

Related Questions