EWS to see shared calendars

This topic contains 1 reply, has 1 voice, and was last updated by Profile photo of Aaron Aaron 3 weeks, 3 days ago.

  • Author
    Posts
  • #57352
    Profile photo of Aaron
    Aaron
    Participant

    Is it possible to use EWS API to see shared calendars that are attached to my outlook profile?

    I'm using this code:

    # Your mailbox here
    $mailboxName = "me@domain.com"
    
    Add-Type -Path "C:\Program Files\Microsoft\Exchange\Web Services\2.2\Microsoft.Exchange.WebServices.dll"  
    $version = [Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2013
    $service = new-object Microsoft.Exchange.WebServices.Data.ExchangeService($version)  
    $service.UseDefaultCredentials = $true  
    $service.AutodiscoverUrl($mailboxName)
    
    $folderid = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Calendar, $mailboxName)
    $calendarFolder = [Microsoft.Exchange.WebServices.Data.calendarFolder]::Bind($service, $folderid)
    $calendarView = new-object Microsoft.Exchange.WebServices.Data.CalendarView([System.DateTime]::Now, [System.DateTime]::Now.AddDays(720))
    $calendarView.MaxItemsReturned = 200;
    $calendarView.PropertySet = new-object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties)
    $result = $calendarFolder.FindAppointments($calendarView)
    
    $result | Format-Table
    

    $folderid only returns the generic, 'calendar'.

    Is there a way to pull shared calendars i've attached through outlook?

  • #57353
    Profile photo of Aaron
    Aaron
    Participant

    Sorry...I've been looking at this too long...

    I just realized I was putting my user name in, not the shared mailbox user...works fine 😉

You must be logged in to reply to this topic.