Skip to content

Commit 9d2cd64

Browse files
authored
Merge pull request O365#133 from robertjdominguez/master
Calendar Pull Sample
2 parents dc7bdc7 + c2e5181 commit 9d2cd64

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

examples/calendarCookbook.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from O365 import *
2+
3+
# User's credentials
4+
e = 'email_address'
5+
p = 'password'
6+
7+
# Create Schedule object, get calendars, and create empty dict
8+
schedule = Schedule((e, p))
9+
result = schedule.getCalendars()
10+
11+
# Funciton to invoke getName() and bind to var result
12+
def cal_name():
13+
result = cal.getName() # This will get the name of a calendar
14+
return result
15+
16+
# Show name of each calendar
17+
print('\nHere are your calendars:\n')
18+
for cal in schedule.calendars:
19+
print(cal_name())
20+
21+
# Get events for each calendar
22+
print('\nHere are all your upcoming events:\n')
23+
for cal in schedule.calendars:
24+
result = cal_name()
25+
events = cal.getEvents() # This will create an Event object
26+
for x in cal.events:
27+
contents = x.getSubject() # This will get the subject
28+
date = x.getStart() # This will get the start time and we'll parse it below
29+
print('{}-{} | {} : {}'.format(date.tm_mon, date.tm_mday, result, contents))

0 commit comments

Comments
 (0)