none
Get free/busy status for a meeting - Outlook 2010 Add in

    Question

  • Hello. I am using Visual Studio 2010 and MS Outlook 2010.

    I am trying to get the free/busy status for a meeting declared in an outlook calendar..

    I can without any problems get the status when the user is free or when he has 'all day event'.

    The problem begins when I want to get a user's status when he's on the meeting that is not a all day event, but lasts for ex. 1hour.

     

    This is my code : 

     

            Outlook.Application oApp = new Outlook.Application();

            Microsoft.Office.Interop.Outlook.NameSpace ns = oApp.Application.Session;


            Outlook.Recipient recipient = ns.CreateRecipient(email);

            DateTime datetime = DateTime.Now;

            string freeBusy = recipient.FreeBusy(datetime, 1, false);

            string status = freeBusy.Substring(0, 1);

     

    I am interested in getting a status now. That's why I start free busy method from Date.Now (1st parameter in freebusy method), and I get only first minute (2nd parameter of free busy method set two 1 character per minute).

    Thanks in advance for any help.

     

     

     

     

    Thursday, January 06, 2011 9:00 AM

Answers

  • Maybe I am missing what the problem is, but if you book an hour long appointment, and the user has another meeeting starting in 30 minutes, your logic will break. You need to check the whole appointment length range for conflicts.
    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    • Proposed as answer by Bessie Zhao Thursday, January 13, 2011 11:09 AM
    • Marked as answer by Bessie Zhao Thursday, January 20, 2011 10:22 AM
    Friday, January 07, 2011 1:49 PM

All replies

  • I am not sure what the problem is. What exactly do you mean by "The problem begins when I want to get a user's status when he's on the meeting that is not a all day event, but lasts for ex. 1hour". What is the problem?
    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Thursday, January 06, 2011 2:25 PM
  • When you create a new meeting in an outlook calendar you can either choose an option "All day event", either you can set a meeting from Start Time to End Time, for example from 11a.m. till 4p.m.

    My add in works only in the first case. So it can tell me if the user is busy when the "All day event" is set.

    But if the user has a meeting from 11 till 16 and I'll try to check the user's status,  for example at 15, my Add in is not working. It tells me that the user is free, even though he has a meeting in his calendar. 

    Thursday, January 06, 2011 2:41 PM
  • Your code only checks the first minute of the appointment. You need to go over the whole duration of your meeting.
    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Thursday, January 06, 2011 8:01 PM
  • I want him to check only first minute, because I want to know if user is busy 'now'.

    But he does not recognise busy in this case even if I check longer period of time than just one minute.

    And I actually check everything (1 minutes per character represented in the returned string) but later I choose only first character of a string.

    Friday, January 07, 2011 8:25 AM
  • I don't know why but it works when instead of method recipient.freebusy I use :

    string freeBusy = recipient.AddressEntry.GetFreeBusy(datetime, 1);

    But the problem is that when I use it, I get security alerts.

    I know that there are no security alerts when redemption is used, but with redemption checking free busy status does not always work and it takes to update the information (for example when you add a meeting, redemption will not see it straight away).

    Friday, January 07, 2011 8:53 AM
  • Maybe I am missing what the problem is, but if you book an hour long appointment, and the user has another meeeting starting in 30 minutes, your logic will break. You need to check the whole appointment length range for conflicts.
    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    • Proposed as answer by Bessie Zhao Thursday, January 13, 2011 11:09 AM
    • Marked as answer by Bessie Zhao Thursday, January 20, 2011 10:22 AM
    Friday, January 07, 2011 1:49 PM
  • i assume that you have since figured this out but for those that stumble upon this please be aware that the return string begins 12:00 am of the day in the datetime parameter. the method ignores the time part. so getting the substring of 0,1 will always give you the status as of the first increment beginning at midnight. to figure out the the status of a person(or room) is at two pm in the afternoon, you need to traverse the return string by your given increment in steps until you arrive at the corresponding character. to reiterate, the method ignores your time part of the parameter and always returns the status increments beginning at 12AM the day of the datetime parameter.
    Tuesday, December 11, 2012 8:55 PM