1

I'm sorry I don't just see what I'm doing wrong (most likely plenty). All I am attempting to do is read the events of a public calendar. I tried to follow the discussions on using public folders but it was a little confusing for a newbie. Using python 2.7.x on OpenSuse 15.0

from exchangelib.folders import Calendar
from exchangelib import Credentials, Account, CalendarItem, UTC_NOW
import datetime
account = Account(...)
account.public_folders_root.refresh()
start = UTC_NOW() - datetime.timedelta(days=7)
print account.public_folders_root.tree()  #this works
x = account.public_folders_root
specificFolder = [item for item in x.walk().get_folders() if item.name == "OC Appointment Calendar"]
leg_folder = Calendar(folder_id = specificFolder[0].id, changekey = specificFolder[0].changekey)
for i in leg_folder.view(start=start, end=start + datetime.timedelta(days=14)):
    print i

testexchange.py", line 15, in <module>
  for i in leg_folder.view(start=start, end=start + datetime.timedelta(days=14)):
File "/usr/lib/python2.7/site-packages/exchangelib/folders.py", line 957, in view
  return FolderCollection(account=self.root.account, folders=[self]).view(*args, **kwargs)

AttributeError: 'NoneType' object has no attribute 'account
Johnf
  • 75
  • 9

1 Answers1

1

It turns out that I wasn't to far off. But here are the code changes that allow access to the appointments.

#specificFolder = [item for item in x.walk().get_folders() if item.name == "OC Appointment Calendar"]
# I was close in above but a better way to find the folder I was looking for is:
specificFolder = list(account.public_folders_root.glob('**/OC Appointment Calendar'))[0]
# Now I can use view()
for item in specificFolder.view(start=start, end=start + datetime.timedelta(days=14)):
    # item now has all the available data
    print item.mime_content
Erik Cederstrand
  • 9,643
  • 8
  • 39
  • 63
Johnf
  • 75
  • 9