1

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("[email protected]")
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.

1 Answer 1

3

I needed to use a different method when setting up the appointment object, which allowed me to use the sharedFolder object:

appointment = sharedCalendar.Items.Add(1)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.