简体   繁体   English

使用python在共享日历中创建约会

[英]Create appointment in shared calendar using python

I prefer not to show my inexperience by posting on here, but this is driving me insane. 我不想在这里发表自己的经验,但是这让我发疯了。

I want to add an appointment to a shared calendar. 我想向共享日历添加约会。 I'm close but can't figure out how to tell it save the item to the shared calendar and not my own default calendar. 我已经接近了,但不知道如何告诉它将项目保存到共享日历,而不是我自己的默认日历。

import win32com.client

outlook = win32com.client.Dispatch("Outlook.Application")
namespace = outlook.GetNamespace("MAPI")

recipient = namespace.createRecipient("owners@email.com")
resolved = recipient.Resolve()
sharedCalendar = namespace.GetSharedDefaultFolder(recipient, 9).Folders("Bookings")

appointment = outlook.CreateItem(1) # 1=outlook appointment item
appointment.Start = '2017-07-17 08:00'
appointment.Subject = "Test booking"
appointment.Duration = 60
appointment.Save()

I have a workaround of replacing appointment.save() with : 我有一个替代方法,用以下方法替换约会。

appointment.Move(sharedCalendar)

and while this does the job, its not the correct way and doesn't help me with working out the next script which needs to read the appointments from the shared calendar. 尽管这样做可以完成工作,但这不是正确的方法,也无法帮助我制定下一个需要从共享日历中读取约会的脚本。

设置约会对象时,我需要使用其他方法,这使我可以使用sharedFolder对象:

appointment = sharedCalendar.Items.Add(1)

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

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