[E2010] [EWSMA] [VB.NET] List calendar items from a shared mailbox using EWS Managed API RRS feed

  • Question

  • Hi,

    I am trying to list the calendar entries for a shared mailbox, but I am not sure how to do it.  I have only just found out about EWS but it seems to be the solution to what I need.

    I have some code that lists the calendar entries for the logged on user and displays them in a text box (just so I can see the info).  The code below shows the main routine that gets the calendar info

    Imports System.Collections.Generic
    Imports System.Linq
    Imports System.Text
    Imports System.Threading.Tasks
    Imports Microsoft.Exchange.WebServices.Data ' This is the Exchange Web Services API.
    Private Sub Button_GetCalendarInfo_Click(sender As Object, e As EventArgs) Handles Button_GetCalendarInfo.Click
    	Dim _EWSExchangeService As New ExchangeService(ExchangeVersion.Exchange2010_SP2)
    	'Use the default credentials of the logged on user
    	_EWSExchangeService.UseDefaultCredentials = True
    	' Call AutoDiscover to return the URL of the most efficient CAS server for a given email address
    	_EWSExchangeService.AutodiscoverUrl("", AddressOf RedirectionUrlValidationCallback) ' this line will only get info from the logged on user
    	'Define a calendar Date range in which to search for appointments
    	Dim EWSCalendarView As New CalendarView(DateTime.Today, DateTime.Today.AddDays(1))
    	' Search for Appointments in the Calendar folder during the time range specified by the CalendarView above
    	Dim appointments As FindItemsResults(Of Appointment) = _EWSExchangeService.FindAppointments(WellKnownFolderName.Calendar, EWSCalendarView)
    	Dim MeetingSensitivity ' What sensitivity is the calendar, i.e. Normal or Private
        Dim MeetingShowAs ' Is the Meeting classed as Free, Tentative, Busy, Out of Office
        For Each meeting In appointments
            TextBox_CalendarEntries.AppendText("Start: " & meeting.Start & "   End: " & meeting.End & "    Subject: " & meeting.Subject & vbTab & vbTab & "   Sensitivity: " & Meeting.Sensitivity & vbTab & "  Status: " & Meeting.LegacyFreeBusyStatus & vbLf)
     End Sub

    I have seen a post where the following was mentioned, but I don't know how to incorporate that into my code.

    FolderId folderToAccess = new FolderId(WellKnownFolderName.Calendar, "<email address of shared calendar>");
    In a FindAppointments call, that would look like:
    service.FindAppointments(new FolderId(WellKnownFolderName.Calendar, "<email address of shared calendar>"), calendarView);
    Any help would be greatly appreciated.

    Thursday, January 22, 2015 3:15 PM

All replies