如何解决无法通过 AppointmentItem 属性检索 Outlook 约会管理器数据
您几乎可以忽略所有代码。主要问题在于 for 循环中字典的“会议组织者”行。我刚刚将其与收到的错误代码一起提供以供参考。
import win32com.client
import datetime as dt
import pandas as pd
outlook = win32com.client.Dispatch('Outlook.Application').GetNamespace('MAPI')
calendar = outlook.GetDefaultFolder(9)
appointments = calendar.Items
appointments.sort('[Start]')
appointments.IncludeRecurrences = True
begin_date = dt.datetime(2020,11,1,12,0)
begin_date_str = dt.datetime.strftime(begin_date,format='%m/%d/%Y %H:%M %p')
end_date = dt.datetime.now() + dt.timedelta(days= 14)
end_date_str = dt.datetime.strftime(end_date,format='%m/%d/%Y %H:%M %p')
appointments = appointments.Restrict("[Start] <= '" + end_date_str + "'")
appointments = appointments.Restrict("[Start] >= '" + begin_date_str + "'")
calendar_df = pd.DataFrame(columns = ['Subject','Start Date','Start Time','End Date','End Time','All day event','Reminder on/off','Reminder Date','Reminder Time','Meeting Organizer','Required Attendees','Optional Attendees','Meeting Resources','Billing Information','Categories','Description','Location','Mileage','Priority','Private','Sensitivity','Show time as','Email'])
for x in appointments:
calendar_df = calendar_df.append({'Subject': x.subject,'Start Date': dt.datetime.strftime(x.Start,format='%m/%d/%Y'),'Start Time': dt.datetime.strftime(x.StartUTC,format='%I:%M %p'),'End Time': dt.datetime.strftime(x.EndUTC,'All day event': x.AllDayEvent,'Categories': x.Categories,'Sensitivity': x.Sensitivity,'Show time as': x.BusyStatus,'Email': str(x.SendUsingAccount)
'Meeting Organizer': x.Organizer
},ignore_index=True)
错误:
com_error: (-2147467259,'Unspecified error',None,None)
当我删除下面的这一行时,所有这些代码都可以正常工作:
'Meeting Organizer': x.Organizer
我在这里参考了 win32com.client 的 AppointmentItem 文档: https://docs.microsoft.com/en-us/previous-versions/office/developer/office-2010/ff869026(v=office.14)#properties
它是一个属性,就像我上面在 for 循环中使用的任何其他属性一样,没有问题。知道是什么原因造成的吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。