Related Entries

Quick Start: Git for personal use
SVN client over SSH to remote Unix server from Windows
Quick Start Grinder - Part V
Quick Start Grinder - Part IV
Quick Start Grinder - Part III

« ADD and antipatterns
» Excel to record expenses

Scripting Outlook Journal

Simple sample JScript code to give you an idea about this

I maintain information about my tasks, meetings etc. in Outlook Journal. Here’s a simple JScript script that exports this information into a delimited format. Yes, Outlook itself can export data like this, but if you want to automate stuff and get it to the next level, this script might help you.

If you save this as sample.js, you can run it like cscript /nologo sample.js

//Get a handle to Outlook; will start it if not already open
var outlook = new ActiveXObject("Outlook.Application");
var namespace = outlook.GetNameSpace("MAPI");
var today = new Date();
var weekago = new Date();weekago.setDate(today.getDate()-7);
var weekagoStr = (weekago.getMonth()+1) + "/" + weekago.getDate() + "/" + weekago.getFullYear();
//I keep a PST file with the name 2007 (or 2008 next year!)
var folderYear = namespace.Folders(""+today.getFullYear());
//Inside that, I’ve a folder named "Journal" where entries are kept
var folderJournal = folderYear.Folders("Journal");
var journalItems = folderJournal.Items(); //all items collection
//take only those items that have a "Start" within a week
//My personal entries have Category as @Home - ignore those
var filteredItems = journalItems.Restrict("[Start] >= '" +  weekagoStr + "' AND [Categories] <> '@Home'");
//loop through the items
for (i=1; i<=filteredItems.Count(); i++) {
    var entry = filteredItems(i);
    //for each item, print a pipe separated record
    WScript.Echo(entry.Type + "|" + entry.Subject + "|"
                + entry.Categories + "|" + entry.Start + "|"
                + entry.End + "|" + entry.Duration/(60) + "|"
                + entry.EntryID);
}