Version 0 of Tcom examples for Microsoft Outlook

Updated 2009-02-12 23:10:20 by SSch

This page provides examples of how to read and write a Microsoft Outlook document using the Tcom package. See How one discovers the API for a COM-exporting application for more help on finding Outlook commands.


Creating a Calendar Entry

 package require tcom

 proc ConvertTime {t} {
  regexp {([+-])(\d\d)(\d\d)} [clock format [clock seconds] -format %z] m sign hours minutes
  set tlocal [expr "$t $sign ($hours *60 +$minutes)*60"]
  return [expr {(25569+$tlocal/24/3600)+(($tlocal%(24*3600))/(24.0*3600))}]
 }

 set outlook   [::tcom::ref getactiveobject Outlook.Application]
 set app       [$outlook Application]
 set entry     [$app CreateItem [expr 1]]

 $entry Subject "This is the subject"
 $entry Start [ConvertTime [clock scan {2009-02-13 21:00}]]
 $entry End [ConvertTime [clock scan {2009-02-13 21:30}]]
 $entry Save