【发布时间】:2014-02-24 00:02:43
【问题描述】:
Outlook 有一些需要 - 比如显示多个月视图
我决定尝试一下,通过 Python 提取事件数据(然后想办法很好地显示它)。 Google 的结果很差。
我的目标是:
- 阅读共享日历
- 读取开始、结束、主题、创建者等事件信息。
这就是我收集到的(灵感来自this site)
import win32com.client, datetime
from dateutil.relativedelta import relativedelta
Outlook = win32com.client.Dispatch("Outlook.Application")
ns = Outlook.GetNamespace("MAPI")
appointments = namespace.GetDefaultFolder(9).Items
# TODO: Need to figure out howto get the shared calendar instead Default [9]
# (I have placed the shared folder into a separate folder - don't know if it matters)
# I would just like the user to select which calendar to execute on
appointments.Sort("[Start]")
appointments.IncludeRecurrences = "True"
begin = date.today().strftime("%m%d%Y")
end = (date.today() + relativedelta( months = 3 )).strftime("%m%d%Y")
appointments = appointments.Restrict("[Start] >= '" +begin+ "' AND [END] >= '" +end+ "'")
我如何遍历事件并阅读它们?
【问题讨论】:
-
您的意思是
ns.GetDefaultFolder(9)而不是namespace.?如果我尝试您的代码,我会收到 NameError。
标签: python python-2.7 outlook-2010 win32com