28
2007
Scripting the Milk: Powering Outlook from Groovy
I’ve always been a TODO list kinda guy and the only product that I’ve found works well with my PocketPC is Outlook. That’s cool when I’m on client sites (since they all run Outlook), except that I’d like to be able to use some other tool when I’m hacking away on my Macbook.
Well lately I’ve been tinkering with Remember The Milk to see what online TODO managers have to offer. I think RTM is even built by a bunch of Aussies, so it gets extra points. The only thing it doesn’t do yet is Outlook integration… But they do offer a pretty comprehensive REST-based API. You know where I’m heading with this right? How hard could it be?
Ok, so a little bit of XmlSlurper action from Groovy and I’m all set and parsing out my tasks straight from RTM method responses. But how am I going to get to my Outlook tasks? Outlook has got some kinda COM story going on…
I’ve used JNIWrapper in the past for getting to COM based stuff, and it works just great – but the upgrade prices were starting to hurt, so I checked out com4j. Very neat little project – and an almost entire replacement for JNIWrapper. Pointed it at my outlook tlb file and voila! Full set of Java classes to match with Outlook… but then I remembered that Guillaume had done some funky Groovy/COM library that he wrote up for Groovy In Action. Grabbed my copy of GINA and checked it out…
Enter Scriptom. This is the COM integration library that I’ve been looking for. No need to generate any classes, just give it a COM object and start calling methods. Takes advantage of Groovy dynamic typing goodness to make it all very easy.
Need to get to your Outlook tasks? Howse about something like:
import org.codehaus.groovy.scriptom.ActiveXProxy
def outlook = new ActiveXProxy("Outlook.Application")
def namespace = outlook.GetNamespace("MAPI")
def taskFolder = namespace.GetDefaultFolder(13) // tasks
def tasks = taskFolder.Items
for (i in 1..tasks.Count.value) {
def task = tasks.Item(i)
if (task.Complete.value == false) {
println task.Subject.value
}
}
Sensational. I’m now in a position where I can get my list of Outlook tasks, and my RTM tasks… now the tricky bit around doing the merge. Both support a “last modified” attribute, so it should be ok to handle the actual time mods, but I’m still not sure how I’m going to handle task renames? I guess I’ll need to tag the RTM entries with an Outlook task id… That could get interesting…
Anways, double thumbs up to Scriptom. Guilluame has done some sensational stuff there. Will post some more when I’ve got something working…
3 Comments + Add Comment
Leave a comment
Glen Smith
Archives
- January 2012
- November 2011
- October 2011
- September 2011
- August 2011
- July 2011
- June 2011
- April 2011
- March 2011
- January 2011
- November 2010
- October 2010
- September 2010
- August 2010
- July 2010
- June 2010
- May 2010
- April 2010
- February 2010
- January 2010
- December 2009
- November 2009
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- October 2006
- September 2006
- August 2006
- July 2006
- June 2006
- May 2006
- April 2006
- March 2006
- February 2006
- January 2006
- December 2005
- November 2005
- October 2005
- September 2005
- August 2005
- July 2005
- June 2005
- May 2005
- April 2005
- March 2005
- February 2005
- January 2005
- December 2004
- November 2004
- October 2004
- September 2004
- August 2004
- July 2004
- June 2004
- May 2004
- March 2004
- February 2004
- January 2004
- December 2003
- November 2003
- October 2003
- September 2003

An article by Glen





Great post. I’ve done a project in JACOB for interfacing with Microsoft Word, Excel, etc, and the Scriptom library actually comes bundled with JACOB. The code is much lighter, and there’s even ways to get IDEs such as NetBeans and Eclipse to work with Groovy. Kudos to your struggles.
-Tres
Hi Glenn!
First off, congrats on the book. A phenomenal effort. I absolutely love it!!!
Now, I was trying to do something similar to what you’re doing (trying to sync RTM with Outlook). What API have you used to add/remove/update tasks in Outlook. I was able to get a list of tasks available in my Outlook using Groovy and Scriptom, but I can’t seem to find the correct API to do CRUD on the tasks.
Cheers,
-Kodeninja
@kodeninja From memory all the crud stuff was all collection based (eg. tasks.sometask.remove() or tasks.add()). If you get stuck, drop me an email and I’ll see if I can dig up the source for the Outlook stuff. Would love to see it re-used somewhere!
Don’t forget to check out http://kenai.com/projects/groovyrtm for a Groovy API to the RTM side, too!
Glen.
(oh. and thanks for the book comments! Glad you liked it!)