RSS category feeds

RSS site feeds

More

Home arrow Script Collection arrow Create Outlook tasks from Taskcoach task file
Create Outlook tasks from Taskcoach task file Print E-mail
This is a script which creates Outlook tasks from each task out of a Taskcoach XML-file. I saved my task to file named "My_Tasks.tsk". Please modify it for your needs.
 
from xml.dom import minidom
import win32com.client
from datetime import datetime
try:
   oOutlookApp = win32com.client.gencache.EnsureDispatch("Outlook.Application")
except:
   print "MSOutlook: unable to load Outlook"
 
# this should use more try/except blocks or nested blocks
#onMAPI = oOutlookApp.GetNamespace("MAPI")
#ofTasks = onMAPI.GetDefaultFolder(win32com.client.constants.olFolderTasks)
 
 
xml = r'My_Tasks.tsk'
 
xmldoc = minidom.parse(xml)
tcTasks = xmldoc.getElementsByTagName('task')
print 'Creating %s tasks'%len(tcTasks)
 
for tcTask in tcTasks:
    print 'Saving %s [%s]' % (tcTask.getAttribute('subject'), tcTask.getAttribute('status'))
    newtask = oOutlookApp.CreateItem(win32com.client.constants.olTaskItem)
    if tcTask.getAttribute('expandedContexts') != 'Dummy': #Todo: Unsichere Ecke
        newtask.Subject = tcTask.getAttribute('subject')
        for note in tcTask.getElementsByTagName('note'):
            newnote = oOutlookApp.CreateItem(win32com.client.constants.olNoteItem)
            newnote.Body += note.getAttribute('subject') + ':\n'
            for nodetext in note.getElementsByTagName('description'):
                newnote.Body += nodetext.firstChild.data
            newnote.Save()
            #newtask.Links.Add(newnote)
 
        for tasktext in tcTask.getElementsByTagName('description'):
                newtask.Body += tasktext.firstChild.data
        for attachment in tcTask.getElementsByTagName('attachment'):
            newtask.Body += 'File attachment %s:\n%s\n' % (attachment.getAttribute('subject'), attachment.getAttribute('location'))
 
        if tcTask.getAttribute('duedate') not in ['', None]:
            newtask.DueDate = tcTask.getAttribute('duedate')
        if tcTask.getAttribute('startdate') not in ['', None]:
            newtask.StartDate = tcTask.getAttribute('startdate')
        #elif tcTask.getAttribute('percentageComplete') in ['0', 0]:
            #newtask.Status = 0
            #newtask.PercentComplete = 0
        if tcTask.getAttribute('percentageComplete') in ['100', 100]:
            newtask.Status = 2
            newtask.PercentComplete = 100
        if tcTask.getAttribute('percentageComplete') not in ['', None, '100', 100]:
            newtask.PercentComplete = int(tcTask.getAttribute('percentageComplete'))
            newtask.Status = 5
        newtask.Save()
 
 
< Prev   Next >

Feedback

Comments

  • Old post but it jsut saved me. Id like to add there are more than 7 types of box... More...
  • Incase someone is looking at this today: I had the same problem, because I tried... More...
  • Hi, I am new to python and I did try above example but not able to play music fi... More...
  • not work error import lib win32ras can you help me for this error More...
  • What difference does this have with the SendKeys method from the "WScript.WShell... More...

Login Form






Lost Password?

My prefered Python IDE

My prefered Python editor is Pyscripter from MMExperts. It is not only an editor. Pyscripter is a full Python IDE including (remote) debugging, a class browser, and all other nice helpers which a full featured IDE needs.

Do you have a script for me ?

Do you have an interesting Python script which does some really cool thing on Windows ? Please post them to this site. It`s very simple - simply copy&paste it to this form. No login is requiered.

Hint: For syntax highlighting and correct Python intendation place your code between html tags <pre> and </pre>.

My prefered web framework

My prefered web framework for developing web applications is Django. Django calls itself The web framework for perfectionists with deadlines. It is a really fast, scalable and (thanks Python) the sexiest web framework of the world.