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.
- MS Outlook 20xx
- Python 2.x
- Python for Windows extension (pywin32 build 216)
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.
Thank you so much Harun.The code works really great. Once again you proved that you are a python genius.
ReplyDeleteGreat code, great example!
ReplyDeleteHow about canceling a meeting request?
Changing the line appt.MeetingStatus = 1 to appt.MeetingStatus = 5
sends out a email cancel request however the meeting is not deleted from the calender.
Thanks,
Bruce
Hi Harun, well I have a scenario that i'm trying to resolve and seems like u'r the man I should talk to about it. So a new team has come to work on our floor and they are keeping the meeting rooms occupied all the times. So i am thinking about a script that can find through and make bookings among the available rooms. the input parameters would be seat_no(can be 4 seter or 8 seter rooms - this is a non negotible criteria, if i am looking for 4 seter i'm ok if a 8 seter gets booked but not the other way around), duration(if duration is 1 hr and no room is available system should check if 2 rooms are available for 30 min each and book both for 30 min[30 min is the minimum] each .. etc). and rooms should belong to a list of rooms(coz otherwise sitting in India i'll end up booking rooms in China or USA) that should be used.
ReplyDeleteAny ideas or code would be highly appreciated man.
-Sandeep
Hi Harun
ReplyDeleteI am getting the following error when trying to run the script from my work computer.
'Outlook Data File'
"Your outlook data file cannot be configured."
"C:\\Users\....(2).ost"
Any idea what could be the problem or the solution?
Hi Prasad,
ReplyDeleteI need python automation code to book meeting rooms in a website..
Please help me out..
Thanks,
Gangadhar
hi harun,
ReplyDeleteIm using win32com.client for sending mail from my Python script. I would like to know how to send an image in the mail body and not as attachment.
please help.
Me too! please!
DeleteHi,
Deletehttps://stackoverflow.com/questions/44544369/i-am-not-able-to-add-an-image-in-email-body-using-python-i-am-able-to-add-a-pi
The above link should help you.
I am also struggling for the same. Managed to embed one image in mail but still struggling to embed multiple images.
Any help is welcome!
Hi all,
ReplyDeletePlease help me to cancel the meeting.
Thanks
Devaraj
Hi,
ReplyDeleteI am able to run the code but I am facing error if outlook application is open.
Thanks,
Srilekha.
Hi,
ReplyDeleteI need to send a meeting with content in .HTMLBody to have text with other style.
Pls!
Hi, I need to set lots of meeting for my manager, who has shared his calendar with me. This code takes default calendar only, is there a change where I can pick another calendar etc.
ReplyDelete