Thunderbird and iCal integration?

Update 2009-05-09: I gave up on this long ago, and switched to using Mail.app.  If you haven’t upgraded to the Thunderbird 3.0 beta, give the Lightning plugin a try.

Warning: This is a very tech-heavy post. So look out.

I get calendar events from my co-workers from time to time, and since they all use Outlook (and I refuse to use Entourage), it’s really more of an irritation than anything else; if I want to put those events into my iCal, I have to save the text of the message to a file, then drag it into iCal. And easy as that is, it’s more effort than I want to go to.

So I thought, “this might be a great thing to use Automator for”. Especially since I hadn’t found anything useful for Automator to do up to that point. Trouble is, there’s no actions to add iCal events (that’s .ics files ya know) from arbitrary files into iCal. Luckily, so long as iCal is your default handler for .ics files, simply opening them (the ics files) will create new events in iCal.

So:
The task at hand is to take a message from Thunderbird (and I really hope the Mozilla developers add drag-and-drop message saving), strip out the calendar event, save it into a text file with a unique name, open that file with iCal, and trash the leftovers.

Here’s how I did it.

First, know that this workflow uses “folder actions”. It’s a nice shortcut, since the action is automatically executed for any file that’s created in or moved into the target folder.

1. “Get Folder Contents”

This is a pretty easy one; it takes the filename from the folder action trigger (which launches the workflow), and passes the file object into the next item.

2. “Run Shell Script’

This one is the real meat of the workflow, and it uses a hell of a lot of perl. A few caveats: You’ll need to install (from CPAN) the following modules: English, Email::Simple, and maybe Carp.
Then, just paste this script into the big box (be sure to select /usr/bin/perl as the Shell). Be aware that there’s a line you need to edit; just set it to the folder that you specify in step 5.

3. “Find Folder Items”

The “Where:” in this script should be the location where you plan to save your email messages (from Thunderbird).
Set the “Whose:” in the script to “Extension is equal to eml”.

4. “Move to Trash”

Fairly simple; after the perl script runs, we no longer need the .eml files.

5. “Find Folder Items”

Be sure to set this item to ignore previous input; I don’t know if it’s necessary or not, since “Move to Trash” doesn’t have any output, but better safe than sorry.
The “Where” in this item should be the same path as in step 2 (remember editing the perl script?), and the “Whose” should be “Extension is equal to ics”.

6. “Open Finder Items”

Open with: iCal.app

7. “Move to Trash”

And since opening the .ics file adds the event to iCal, we no longer need the source. So we get rid of it.

Then just save the workflow as a folder action on the same folder you specified in step 3.

And that’s it. I’m sure there’s a more elegant way to do this, so suggestions are certainly welcome. I may even use them.

Published by

devlogic

I write stuff on this blog. All of the stuff.