首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >获取Outlook约会后无法调用win32com.client.Dispatch AppointmentItem的“Size”属性

获取Outlook约会后无法调用win32com.client.Dispatch AppointmentItem的“Size”属性
EN

Stack Overflow用户
提问于 2018-06-07 20:08:23
回答 1查看 67关注 0票数 0

我正在使用win32com.client访问Outlook应用程序。我成功地从日历中获得了约会,但我对在不进入for循环的情况下获得约会的数量感兴趣。

我正在做以下工作:

代码语言:javascript
复制
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application")
namespace = outlook.GetNamespace('MAPI')

appointments = namespace.GetDefaultFolder(9).Items

appointments.Sort("[Start]")
appointments.IncludeRecurrences = "True"

restriction = "[Start] >= '" + start_date.strftime('%Y.%m.%d') + "' AND [Start] <= '" + \
              end_date.strftime('%Y.%m.%d') + "'"
restricted_items = appointments.Restrict(restriction)
print(restricted_items.Size)

从描述Outlook的this链接中,我发现我可以获得AppointmentItem对象的大小。但是它抛出了一个异常

代码语言:javascript
复制
AttributeError: '<win32com.gen_py.Microsoft Outlook 15.0 Object Library._Items instance at 0x73837256>' object has no attribute 'size'

我做错了什么?

顺便说一下,我想使用它来检查作为上述查询的结果而检索到的任何约会,这样我就不会在None上使用restriction对象。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-06-09 04:02:53

Restrict返回Items集合。它不会公开Size属性--您需要的是Count

如果事先不知道集合的大小(Outlook按需计算),则使用Items.GetFirst/GetNext遍历集合中的项。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50740835

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档