jamppi
asked on
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.
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.