EWS get resource room bookings

Hi!  
i need to get all the bookings from a resource "Room" named e.g.   xxx@.x.se
using EWS
could somebody show how i can get a list off all appointments in the room.



Private Sub listRoomEvents()

        Dim service As ExchangeService = ConnectToServer(user, pass)

        Dim folderView = New FolderView(100)
        folderView.Traversal = FolderTraversal.Deep

        folderView.PropertySet = New PropertySet(FolderSchema.FolderClass, FolderSchema.DisplayName, FolderSchema.TotalCount, FolderSchema.ParentFolderId)
        folderView.PropertySet.Add(AppointmentSchema.Resources)

        Dim folders As FindFoldersResults = service.FindFolders(WellKnownFolderName.Calendar, folderView)
        ' Process each item.

        For Each myFolder As Folder In folders.Folders
            If TypeOf myFolder Is CalendarFolder Then
                Dim calendar = TryCast(myFolder, CalendarFolder)
                ' Initialize values for the start and end times, and the number of appointments to retrieve.
                Dim startDate As DateTime = DateTime.Now
                Dim endDate As DateTime = startDate.AddDays(30)
                Const NUM_APPTS As Integer = 15
                ' Set the start and end time and number of appointments to retrieve.
                Dim cView As New CalendarView(startDate, endDate, NUM_APPTS)
                ' Limit the properties returned to the appointment's subject, start time, and end time.
                cView.PropertySet = New PropertySet(AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.[End])
                ' Retrieve a collection of appointments by using the calendar view.
                Dim appointments As FindItemsResults(Of Appointment) = calendar.FindAppointments(cView)
                For Each a As Appointment In appointments
                    Console.Write("Subject: " + a.Subject.ToString() + " ")
                    Console.Write("Start: " + a.Start.ToString() + " ")
                    Console.Write("End: " + a.[End].ToString())
                    Console.WriteLine()
                Next
            End If
        Next



    End Sub

Open in new window

jamppiAsked:
Who is Participating?
 
CodeCruiserCommented:
Does this work?

Dim StartDate As DateTime = DateTime.Today
Dim EndDate As DateTime = DateTime.Today.AddMonths(2)
Dim cv As New CalendarView(StartDate, EndDate)
Dim MailboxToAccess As [String] = "user@domain.com"
Dim CalendarFolderId As New FolderId(WellKnownFolderName.Calendar, MailboxToAccess)
Dim fapts As FindItemsResults(Of Appointment) = service.FindAppointments(CalendarFolderId, cv)
If fapts.Items.Count > 0 Then
	For Each Appoint As Appointment In fapts
		Console.WriteLine(Appoint.Start)
		Console.WriteLine(Appoint.Subject)
	Next
End If

Open in new window


https://social.msdn.microsoft.com/Forums/silverlight/en-US/440926e7-1f1c-4f1e-8f23-7971fe3867b9/get-all-appointments-from-a-resourceroom-in-exchange-online2010-with-ews?forum=exchangesvrdevelopment
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.