(c) 2013 LinkedIn Corp. All rights reserved. Licensed under the Apache License, Version 2.0 (the “License”);?you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software?distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

Exchange2010CalendarEvent

class pyexchange.exchange2010.Exchange2010CalendarEvent(service, id=None, calendar_id=u'calendar', xml=None, **kwargs)[source]
id

Read-only. The internal id Exchange uses to refer to this event.

subject

The subject or title of the event.

start

The start time and date of the event. Should be a non-naive (i.e. with timezone) datetime object.

end

The end time and date of the event. Should be a non-naive (i.e. with timezone) datetime object.

location

The location of the event. This is a string.

html_body

The HTML version of the message. Either this or text_body must be set.

text_body

The text version of the message. Either this or html_body must be set.

body

Read-only. Returns either html_body or text_body, whichever is set. If both are set, html_body is returned.

organizer

Read-only. The organizer of the event.

This returns a ExchangeEventOrganizer object.

attendees

All attendees invited to this event.

Iterating over this property yields a list of ExchangeEventResponse objects:

for person in event.attendees:
  print person.name, person.response

You can set the attendee list by assigning to this property:

event.attendees = [u'somebody@company.foo',
                   u'somebodyelse@company.foo']

If you add attendees this way, they will be required for the event.

To add optional attendees, either use optional_attendees or add people using the ExchangeEventAttendee object:

from pyexchange.base import ExchangeEventAttendee

attendee = ExchangeEventAttendee(name="Jane Doe",
                                 email="jane@her.email",
                                 required=False)

event.attendees = attendee

Attendees must have an email address defined.

required_attendees

Required attendees for this event.

event.required_attendees = [u'important_person@company.foo',
                            u'admin@company.foo']

for person in event.required_attendees:
  print person.email

This property otherwise behaves like attendees.

optional_attendees

Optional attendees for this event.

event.optional_attendees = [u'maybe@company.foo',
                            u'other_optional@company.foo']

for person in event.optional_attendees:
  print person.email

This property otherwise behaves like attendees.

resources

Resources (aka conference rooms) for this event.

event.resources = [u'conferenceroom@company.foo']

for room in event.resources:
  print room.email

This property otherwise behaves like attendees.

conference_room

Read-only. A property to return the first resource, since the most common use case is a meeting with one resource (the conference room).

event.resources = [u'conferenceroom@company.foo']

print event.conference_room.email # u'conferenceroom@company.foo'

Returns a ExchangeEventAttendee object.

recurrence

A property to set the recurrence type for the event. Possible values are: ‘daily’, ‘weekly’, ‘monthly’, ‘yearly’.

recurrence_interval

A property to set the recurrence interval for the event. This should be an int and applies to the following types of recurring events: ‘daily’, ‘weekly’, ‘monthly’. It should be a value between 1 and 999 for ‘daily’. It should be a value between 1 and 99 for ‘weekly’ and ‘monthly’.

recurrence_end_date

Should be a datetime.date() object which specifies the end of the recurrence.

recurrence_days

Used in a weekly recurrence to specify which days of the week to schedule the event. This should be a string of days separated by spaces. ex. “Monday Wednesday”

conflicting_event_ids

Read-only. The internal id Exchange uses to refer to conflicting events.

add_attendee(attendees, required=True)

Adds new attendees to the event.

attendees can be a list of email addresses or ExchangeEventAttendee objects.

event.attendees = [u'jane@company.foo',
                   u'jack@company.foo']
event.add_attendee([u'chrissie@company.foo'])

print len(event.attendees) # prints 3

If required is true, attendees will be marked as required. Otherwise, they’ll be optional.

remove_attendees(attendees)

Removes attendees from the event.

event.attendees = [u'jane@company.foo',
                   u'jack@company.foo',
                   u'chrissie@company.foo']
event.remove_attendees([u'jack@company.foo', u'chrissie@company.foo'])

print len(event.attendees) # prints 1

attendees can be a list of email addresses or ExchangeEventAttendee objects.

add_resources(resources)

Adds new resources to the event.

event.resources = [u'room@company.foo']
event.add_resources([u'projector@company.foo'])

print len(event.attendees) # prints 2

resources can be a list of email addresses or ExchangeEventAttendee objects.

remove_resources(resources)

Removes resources from the event.

event.resources = [u'room@company.foo',
                   u'projector@company.foo']
event.remove_resources(u'projector@company.foo')

print len(event.attendees) # prints 1

resources can be a list of email addresses or ExchangeEventAttendee objects.

cancel()[source]

Cancels an event in Exchange.

event = service.calendar().get_event(id='KEY HERE')
event.cancel()

This will send notifications to anyone who has not declined the meeting.

conflicting_events()[source]

This will return a list of conflicting events.

Example:

event = service.calendar().get_event(id='<event_id>')
for conflict in event.conflicting_events():
  print conflict.subject
create()[source]

Creates an event in Exchange.

event = service.calendar().new_event(
  subject=u"80s Movie Night",
  location = u"My house",
)
event.create()

Invitations to attendees are sent out immediately.

get_master()[source]
Raises:InvalidEventType – When this method is called on an event that is not a Occurrence type.

This will return the master event to the occurrence.

Examples:

event = service.calendar().get_event(id='<event_id>')
print event.type  # If it prints out 'Occurrence' then that means we could get the master.

master = event.get_master()
print master.type  # Will print out 'RecurringMaster'.
get_occurrence(instance_index)[source]
Parameters:

instance_index (iterable) – This should be tuple or list of integers which correspond to occurrences.

Raises:
  • TypeError – When instance_index is not an iterable of ints.
  • InvalidEventType – When this method is called on an event that is not a RecurringMaster type.

This will return a list of occurrence events.

Examples:

master = service.calendar().get_event(id='<event_id>')

# The following will return the first 20 occurrences in the recurrence.
# If there are not 20 occurrences, it will only return what it finds.
occurrences = master.get_occurrence(range(1,21))
for occurrence in occurrences:
  print occurrence.start
move_to(folder_id)[source]
Parameters:folder_id (str) – The Calendar ID to where you want to move the event to.

Moves an event to a different folder (calendar).

event = service.calendar().get_event(id='KEY HERE')
event.move_to(folder_id='NEW CALENDAR KEY HERE')
resend_invitations()[source]

Resends invites for an event.

event = service.calendar().get_event(id='KEY HERE')
event.resend_invitations()

Anybody who has not declined this meeting will get a new invite.

update(calendar_item_update_operation_type=u'SendToAllAndSaveCopy', **kwargs)[source]

Updates an event in Exchange.

event = service.calendar().get_event(id='KEY HERE')
event.location = u'New location'
event.update()

If no changes to the event have been made, this method does nothing.

Notification of the change event is sent to all users. If you wish to just notify people who were added, specify send_only_to_changed_attendees=True.

Exchange2010FolderService

class pyexchange.exchange2010.Exchange2010FolderService[source]
find_folder(parent_id)[source]
Parameters:parent_id (str) – The parent folder to list.

This method will return a list of sub-folders to a given parent folder.

Examples:

# Iterate through folders within the default 'calendar' folder.
folders = service.folder().find_folder(parent_id='calendar')
for folder in folders:
  print(folder.display_name)

# Delete all folders within the 'calendar' folder.
folders = service.folder().find_folder(parent_id='calendar')
for folder in folders:
  folder.delete()
get_folder(id)[source]
Parameters:id (str) – The Exchange ID of the folder to retrieve from the Exchange store.

Retrieves the folder specified by the id, from the Exchange store.

Examples:

folder = service.folder().get_folder(id)
new_folder(display_name=display_name, folder_type=folder_type, parent_id=parent_id)[source]
Parameters:
  • display_name (str) – The display name given to the new folder.
  • folder_type (str) – The type of folder to create. Possible values are ‘Folder’, ‘CalendarFolder’, ‘ContactsFolder’, ‘SearchFolder’, ‘TasksFolder’.
  • parent_id (str) – The parent folder where the new folder will be created.

Creates a new folder with the given properties. Not saved until you call the create() method.

Examples:

folder = service.folder().new_folder(
  display_name=u"New Folder Name",
  folder_type="CalendarFolder",
  parent_id='calendar',
)
folder.create()

Exchange2010Folder

class pyexchange.exchange2010.Exchange2010Folder[source]
id

Read-only. The internal id Exchange uses to refer to this folder.

parent_id

Read-only. The internal id Exchange uses to refer to the parent folder.

folder_type

The type of folder this is. Can be one of the following:

'Folder', 'CalendarFolder', 'ContactsFolder', 'SearchFolder', 'TasksFolder'
display_name

The name of the folder.

create()[source]

Creates a folder in Exchange.

calendar = service.folder().new_folder(
  display_name=u"New Folder Name",
  folder_type="CalendarFolder",
  parent_id='calendar',
)
calendar.create()
delete()[source]

Deletes a folder from the Exchange store.

folder = service.folder().get_folder(id)
print("Deleting folder: %s" % folder.display_name)
folder.delete()
move_to(folder_id)[source]
Parameters:folder_id (str) – The Folder ID of what will be the new parent folder, of this folder.

Move folder to a different location, specified by folder_id:

folder = service.folder().get_folder(id)
folder.move_to(folder_id="ID of new location's folder")