0

I'm trying to access and read "Shared Calendars" based on pyexchange and the following code:

from pyexchange import Exchange2010Service, ExchangeNTLMAuthConnection
from datetime import datetime
from pytz import timezone

#Connection
URL = 'https://<server name>/EWS/Exchange.asmx'
USERNAME = '<Domain>\\<User Name>'
PASSWORD = '<Your Password>'

# Set up the connection to Exchange
connection = ExchangeNTLMAuthConnection(url=URL,
                                        username=USERNAME,
                                        password=PASSWORD)

service = Exchange2010Service(connection)

# List all events from date to date
calendar_list = service.calendar().list_events(
    start=timezone('Europe/Amsterdam').localize(datetime(2016, 6, 1)),
    end=timezone('Europe/Amsterdam').localize(datetime(2016, 6, 30)),
    details=True
)

for event in calendar_list.events:
    print("{start} ------ {stop} ------ {subject}".format(
        start=event.start,
        stop=event.end,
        subject=event.subject
    ))

Everything works great with my Calendar, but I don't know how to do the same for the 3 "Shared Calendars": Screenshot of my calendar view

Any idea how to list the 3 "Shared Calendars"? I'm using Outlook on a Mac.

Nicolas
  • 79
  • 7

1 Answers1

2

I could resolve same issue.

 connection = ExchangeNTLMAuthConnection(url=URL,
                                    username=USERNAME,
                                    password=PASSWORD)
 service = Exchange2010Service(connection)
 my_calendar = service.calendar()
 events = my_calendar.list_events(
     start=timezone("US/Eastern").localize(datetime(2014, 10, 1, 11, 0, 0)),
     end=timezone("US/Eastern").localize(datetime(2014, 10, 29, 11, 0, 0)),
     details=True,
     delegate_for=u'his_email_address@abc.com' ### This is the key point!!
 )
 for event in events.events:
     print "{start} {stop} - {subject}".format(
         start=event.start,
         stop=event.end,
         subject=event.subject
     )

You may use "delegate_for" option. You may need to use pyexchange 0.7-dev for this.

Run below to install it.

sudo pip install git+https://github.com/linkedin/pyexchange.git
Anonymus
  • 21
  • 2