EWS: Access shared calendars
Asked Answered
A

4

7

I am trying to use Exchange Web Services to access calendar data, but I can't seem to figure out how to access calendars which have been shared by other users when it is not their default calendar. Assuming another user in my company created a shared calendar and shared it with me, I can't even find the calendar folder, let alone get the items within it.

The answers can be in terms of the EWS Managed API (version 1.0 or 1.1), the service objects directly, or even just the XML body of the SOAP message that needs to be sent to the server. I just need some kind of starting point. Any help would be greatly appreciated.

Alkmaar answered 18/11, 2010 at 17:4 Comment(0)
I
7

Here's how I managed to do it:

Dim _cal As New Microsoft.Exchange.WebServices.Data.FolderId(Microsoft.Exchange.WebServices.Data.WellKnownFolderName.Calendar, New Microsoft.Exchange.WebServices.Data.Mailbox(_otherAddress))
Dim _calendarView As New Microsoft.Exchange.WebServices.Data.CalendarView(_startTime.Date, _endTime.Date.AddDays(1))

For Each appointmentItem As Microsoft.Exchange.WebServices.Data.Appointment In _
    service.FindAppointments( _
    _cal, _
    _calendarView)
Next

Note: this only works for the default calendar as that is all I needed for my requirements

Edit: For non-default calendars, have you looked into the ExchangeService.FindFolders method, I have not tried but this might not require root inbox access.

Infecund answered 2/3, 2011 at 6:4 Comment(3)
Thanks Seph, but as I stated in my question, I need access to a shared non-default calendar.Alkmaar
I edited my answer see if that helps, another option is to have your users subscribe their shared calendars automatically (so on the user side you tell your server what the folderId is for this user), this would not require you to have root access to the mailboxInfecund
What permissions/role does the ExchangeService.Credentials account need?Levator
T
3

This is rather complicated, because you need the FolderId of the folder in question. In addition to access to the calendar folder you'll need read access to the root folder of the mailbox. This allows you to execute a FindFolder operation to retrieve that id.

Talavera answered 21/11, 2010 at 20:14 Comment(1)
I don't see why that would be necessary. Forgetting about EWS, if I don't have read access to another employee's root folder, but they create a shared folder and share it with me through Outlook, I can see it. Does them sharing the folder automatically give me read access to their root folder? If not, why would Outlook be able to view the shared calendar but not EWS?Alkmaar
B
1

I know it's a couple of years after the original post, but just to help people with similar problems, look at this.

It uses the EWS API's WellKnownFolderName.PublicFoldersRoot to access the public folder and browses to the requested subfolder using FolderId's.

Barbbarba answered 22/10, 2013 at 8:42 Comment(0)
S
0

If you need to do this in Java, here's and answer that could help. Office365 API - Admin accessing another users/room's calendar events. It's got a working sample of code. Until MS gets the Azure V2.0 REST API working, this is the way to do it.

Squabble answered 19/8, 2016 at 15:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.