如何使用 Python 将 Outlook 日历事件添加到共享日历

问题描述 投票:0回答:1

有了这个 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")

python outlook win32com office-automation outlook-calendar
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.