With this python code I can make an outlook event in my personal calendar but I would like to make an event in a shared outlook calendar.
FolderPath of the outlook calendar: \Public Folders - my.email@company.com\All Public Folders\COMPANY\Production Can somebody please help me?
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application")
ns = outlook.GetNamespace("MAPI")
#FolderPath of the outlook calendar: \\Public Folders - my.email@company.com\All Public Folders\COMPANY\Production
calendar_folder = ns.Session.Folders('Public Folders - my.email@company.com').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")