Create Outlook calendar item with Python

I've created this script when I needed to keep track of my street workout performance. I was needed to have a reminder for each day that will tell me how much repetitions I should do today.
So this script will create a bunch of Microsoft Outlook appointments in your calendar according to the "table" dictionary. The table is reduced for this example. It is easier to create such table in MS Excel, then convert it to text and paste into your favourite Python IDE. Please note that this code is using PyWin32 library.

def addevent(start, subject):
    import win32com.client
    oOutlook = win32com.client.Dispatch("Outlook.Application")
    appointment = oOutlook.CreateItem(1) # 1=outlook appointment item
    appointment.Start = start
    appointment.Subject = subject
    appointment.Duration = 20
    appointment.Location = 'Sprortground'
    appointment.ReminderSet = True
    appointment.ReminderMinutesBeforeStart = 1
    appointment.Save()
    return

table = {"11-16":20, "12-1":30, "12-16":40, "12-31":50}

for item in table.keys():
    start = '2012-' + item + ' 18:35'
    subject = 'P-bars. To do:' + str(table[item])
    addevent(start, subject)

Comments

Post a Comment

Popular posts from this blog

How to uninstall a broken software

Xerox 116-324 fault when printing .doc or .pdf containing callibri fonts