简体   繁体   English

Python ExchangeLib更新日历项目hinter_is_set

[英]Python ExchangeLib Update Calendar Item reminder_is_set

All, 所有,

I am new to Python, and I am having issues updating the reminder_is_set property on calendar items. 我是Python的新手,在更新日历项的reminder_is_set属性时遇到问题。 I am trying to get my calendar items from now and 7 days ahead and turn off the reminders. 我正在尝试从现在开始和7天之前获取日历项目,并关闭提醒功能。

I can get the calendar items in the view just fine. 我可以在视图中获取日历项目。 I can enumerate the items just fine. 我可以列举这些项目。 I just can't seem to figure out how to update the value and save each item. 我似乎无法弄清楚如何更新值并保存每个项目。 I looked at the examples and see the bulk update sample, but I don't see where the value is being set between the fetch and the bulk update call. 我查看了示例并看到了批量更新示例,但没有看到在获取和批量更新调用之间的值设置位置。 Any and all help appreciated. 任何和所有帮助表示赞赏。

calendar_items = account.calendar.view(start=startDate, end=currentDateTime)

calendar_ids = [(i.id, i.changekey) for i in calendar_items]

items_iter = account.fetch(ids=calendar_ids, only_fields='reminder_is_set')
for item in items_iter:
    item.reminder_is_set = False

updated_ids = account.bulk_update(items=[(i, ('reminder_is_set')) for i in calendar_items])

The main problem is that your changes are in items_iter but you are calling bulk_update() with calendar_items which doesn't have the changes. 主要问题是您的更改在items_iter但是您正在使用calendar_items调用bulk_update() ,而没有更改。

Here's an example that should work: 这是一个可行的示例:

update_pairs = []
for item in account.calendar\
        .view(start=startDate, end=currentDateTime)\
        .only('reminder_is_set'):
    if item.reminder_is_set:
        item.reminder_is_set = False
        update_pairs.append((item, ('reminder_is_set',)))

updated_ids = account.bulk_update(items=update_pairs)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM