none
Get all appointments from a resource(room) in Exchange Online(2010) with EWS

    Question

  • Hello technet,

    Speccs: Visual Studio 2010, Exchange Online (2010), Using Exchange Web Service API and C#.

    I need to display the next 2 meetings(appointments) from all my room-resources.

    I can get all my own appointments when I bind the service to my personal exchangeprofile using EWS, but this is not possible for the rooms because they are resources.

    Just to be clear, - I am looking for something that can return a list of all meetings(appointments) in a desired room(resource).

    I really hope someone can help me!

    Thanks in advance, Mads.


    Tuesday, September 17, 2013 2:24 PM

Answers

  • To query another mailbox's calendar you need to have at least reviewer rights to that the folder (eg you should be able to open that folder in Outlook with the user your going to run the query as).If you cant do that use Add-MailboxFolderPermission to add rights

    Using the EWS Managed API http://msdn.microsoft.com/en-us/library/dd633696(v=exchg.80).aspx you can then use something like this to query the next 2 months of appointments (if you want more just adjust the Start and End dates)

                DateTime StartDate = DateTime.Today;
                DateTime EndDate = DateTime.Today.AddMonths(2);
                CalendarView cv = new CalendarView(StartDate, EndDate);
                String MailboxToAccess = "user@domain.com";
                FolderId CalendarFolderId = new FolderId(WellKnownFolderName.Calendar, MailboxToAccess);
                FindItemsResults<Appointment> fapts = service.FindAppointments(CalendarFolderId, cv);
                if (fapts.Items.Count > 0)
                {
                    foreach (Appointment Appoint in fapts)
                    {
                        Console.WriteLine(Appoint.Start);
                        Console.WriteLine(Appoint.Subject);
                    }
                }
    Cheers
    Glen

    • Marked as answer by Mads SP Wednesday, September 18, 2013 9:39 AM
    Wednesday, September 18, 2013 5:11 AM

All replies

  • To query another mailbox's calendar you need to have at least reviewer rights to that the folder (eg you should be able to open that folder in Outlook with the user your going to run the query as).If you cant do that use Add-MailboxFolderPermission to add rights

    Using the EWS Managed API http://msdn.microsoft.com/en-us/library/dd633696(v=exchg.80).aspx you can then use something like this to query the next 2 months of appointments (if you want more just adjust the Start and End dates)

                DateTime StartDate = DateTime.Today;
                DateTime EndDate = DateTime.Today.AddMonths(2);
                CalendarView cv = new CalendarView(StartDate, EndDate);
                String MailboxToAccess = "user@domain.com";
                FolderId CalendarFolderId = new FolderId(WellKnownFolderName.Calendar, MailboxToAccess);
                FindItemsResults<Appointment> fapts = service.FindAppointments(CalendarFolderId, cv);
                if (fapts.Items.Count > 0)
                {
                    foreach (Appointment Appoint in fapts)
                    {
                        Console.WriteLine(Appoint.Start);
                        Console.WriteLine(Appoint.Subject);
                    }
                }
    Cheers
    Glen

    • Marked as answer by Mads SP Wednesday, September 18, 2013 9:39 AM
    Wednesday, September 18, 2013 5:11 AM
  • Hello Glenn, thank you for the fast reply.

    This was exactly what I was looking for!

    I was mistakenly using the following binding:

    CalendarFolder cfolder = CalendarFolder.Bind(service, WellKnownFolderName.Calendar);

    You have saved me alot of time :)

    Cheers

    Wednesday, September 18, 2013 9:39 AM
  • Actually, this code will only return appointments which this account joined as attendee, not as resource.

    At least, it does not work in Exchange 2013.

    Friday, February 19, 2016 4:37 AM
  • Hey Glen, 

    Iam sorry for my late request concerning the same thing, I apologize.

    I am really far from programming and would like to ask if it is possible to use this code against Exchange 2007 SP3 ?

    May thanks for your help,

    Monday, January 09, 2017 9:52 AM
  • Sure it should work fine on Exchange 2007.

    cheers
    Glen

    Tuesday, January 10, 2017 4:29 AM
  • This does work fine in the Outlook 365. Thanks Glen
    Friday, May 12, 2017 2:04 AM
  • Check for the Calander Access. or check if the conference Room is allocated as on resource.
    Friday, May 12, 2017 2:05 AM
  • There is an issue with this approach, is that the Subject contains the Organizer's name instead of the actual Appointment subject. By default, the subject is overwritten with Organizer's name when invite is sent to room. This configuration can be turned off by issuing below command at Exchange Management Shell


    Set-CalendarProcessing -Identity <RESOURCEMAILBOX> -DeleteSubject $False -AddOrganizerToSubject $False

    Reference : https://support.microsoft.com/en-us/help/2842288/resource-mailbox-s-calendar-shows-the-organizer-s-name-instead-of-the


    Tuesday, May 15, 2018 9:06 AM