有了这个 python 代码,我可以在我的个人日历中创建一个 outlook 事件,但我想在一个共享的 outlook 日历中创建一个事件。
outlook日历的文件夹路径:\Public Folders - [email protected]\All Public Folders\COMPANY\Production 有人可以帮我吗?
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application")
ns = outlook.GetNamespace("MAPI")
#FolderPath of the outlook calendar: \\Public Folders - [email protected]\All Public Folders\COMPANY\Production
calendar_folder = ns.Session.Folders('Public Folders - [email protected]').Folders("All Public Folders").Folders("COMPANY").Folders("Production")
def Add_outlook_Event(when,subject):
appt = outlook.CreateItem(1) #<-- this works
#appt = outlook.calendar_folder.CreateItem(1) <-- this does not work
#appt = calendar_folder.CreateItem(1) <-- this does not work
appt.Start = when # yyyy-MM-dd hh:mm
appt.Subject = subject
appt.AllDayEvent = True
appt.Save()
appt.Send()
Add_outlook_Event("2023-03-10","New Outlook event for Bobby")