Tuesday, 31 January 2012

Python: Make a Meeting Request / an Appointment in MS Outlook

Have you ever wanted to automate the setting up of meeting requests and/or appointments on MS Outlook from python language?
Here are the tools/packages used for the below scripts.
  1. MS Outlook 20xx
  2. Python 2.x
  3. Python for Windows extension (pywin32 build 216)
Setting up an Appointment

import win32com.client
oOutlook = win32com.client.Dispatch("Outlook.Application")
appt = oOutlook.CreateItem(1) # 1 - olAppointmentItem
appt.Start = '2012-01-28 17:00'
appt.Subject = 'Follow Up Meeting'
appt.Duration = 15
appt.Location = 'Office - Room 132A'
appt.Save()
print "Done"

This will place a appointment in your default account setup in MS Outlook

Setting up a Meeting Request

Meeting request in outlook are slight variations of appointments. So first an appointment has to be created and convert it to appointment, buy setting meeting status property.

import win32com.client
oOutlook = win32com.client.Dispatch("Outlook.Application")
appt = oOutlook.CreateItem(1) # 1 - olAppointmentItem
appt.Start = '2012-01-28 17:00'
appt.Subject = 'Follow Up Meeting'
appt.Duration = 15
appt.Location = 'Office - Room 132A'
appt.MeetingStatus = 1 # 1 - olMeeting; Changing the appointment to meeting
#only after changing the meeting status recipients can be added
appt.Recipients.Add("recipient1@somedomain.com")
appt.Save()
appt.Send()
print "Done"

Let me know if you want to automatically accept certain meeting requests automatically though similar python script as above.

Here is the story for this post. One of my former colleague and friend was spending about 45 mins every week setting up meeting requests with few participants based on some conditional fulfillment, which was cumbersome and errorprone. So he was looking for a way to automate it and approached me.