EWS get resource room bookings

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)

        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())
            End If

    End Sub

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
End If

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.