| 1 |
ninoborges |
8 |
"""
|
| 2 |
|
|
A program for Jim to import, from a csv export of someother calendar, into outlook
|
| 3 |
|
|
|
| 4 |
|
|
Created by
|
| 5 |
|
|
Emanuel Borges
|
| 6 |
|
|
10.11.2007
|
| 7 |
|
|
|
| 8 |
|
|
|
| 9 |
|
|
"""
|
| 10 |
|
|
|
| 11 |
|
|
|
| 12 |
|
|
from win32com.client import Dispatch
|
| 13 |
|
|
from win32com.client import constants
|
| 14 |
|
|
import time
|
| 15 |
|
|
|
| 16 |
|
|
|
| 17 |
|
|
def main():
|
| 18 |
|
|
global o
|
| 19 |
|
|
o=Dispatch("Outlook.Application.11")
|
| 20 |
|
|
print "Program started. Waiting 20 minutes."
|
| 21 |
|
|
starttime = ConvertDate() + ", 2007 03:00 pm"
|
| 22 |
|
|
endtime = ConvertDate() + ", 2007 4:00 pm"
|
| 23 |
|
|
#time.sleep(1200)
|
| 24 |
|
|
print "20 minutes have passed. Creating appointment."
|
| 25 |
|
|
CalendarEntry("Gone to gym","Capital Club",starttime,endtime)
|
| 26 |
|
|
print "Calendar Entry has been created."
|
| 27 |
|
|
|
| 28 |
|
|
def CalendarEntry(sub,loc,starttime,endtime):
|
| 29 |
|
|
appointment = o.CreateItem(constants.olAppointmentItem)
|
| 30 |
|
|
appointment.Subject = sub
|
| 31 |
|
|
appointment.Location = loc
|
| 32 |
|
|
appointment.Start = starttime
|
| 33 |
|
|
appointment.End = endtime
|
| 34 |
|
|
appointment.Save()
|
| 35 |
|
|
|
| 36 |
|
|
def ConvertDate():
|
| 37 |
|
|
now = time.localtime()
|
| 38 |
|
|
date = now[1]
|
| 39 |
|
|
date2 = now[2]
|
| 40 |
|
|
date = str(date) + " " + str(date2)
|
| 41 |
|
|
return date
|
| 42 |
|
|
|
| 43 |
|
|
|
| 44 |
|
|
if __name__ == "__main__":
|
| 45 |
|
|
global o
|
| 46 |
|
|
o=Dispatch("Outlook.Application.11")
|
| 47 |
|
|
contents = open(r"C:\Test_dir\Calendar_export.txt").readlines()
|
| 48 |
|
|
for line in contents:
|
| 49 |
|
|
nul, nul, nul, nul, stDate, stTime, endDate, endTime, sub = line.split("|")
|
| 50 |
|
|
stDate = stDate.replace("^","")
|
| 51 |
|
|
stTime = stTime.replace("^","")
|
| 52 |
|
|
endDate = endDate.replace("^","")
|
| 53 |
|
|
endTime = endTime.replace("^","")
|
| 54 |
|
|
sub = sub.replace("^","")
|
| 55 |
|
|
stMonth, stDay, stYear = stDate.split("/")
|
| 56 |
|
|
stDtTm = "%s %s, %s %s"% (stMonth, stDay, stYear, stTime)
|
| 57 |
|
|
endMonth, endDay, endYear = endDate.split("/")
|
| 58 |
|
|
endDtTm = "%s %s, %s %s"% (endMonth, endDay, endYear, endTime)
|
| 59 |
|
|
print "%s | %s | %s"% (stDtTm, endDtTm, sub)
|
| 60 |
|
|
CalendarEntry(sub, "", stDtTm, endDtTm) |