Gecko 2 has the very cool Services module, which gives JavaScript code quick access to a list of commonly-used XPCOM services. No more remembering an arcane contract ID every time you need to access, say, the preferences service – all you need to do is type in Services.prefs.
A few days ago, I proposed adding a similar module called MailServices for access to mail/news services. The module is now available for Thunderbird and SeaMonkey’s core and extension developers to use – if you’re in a Thunderbird mail window’s scope, it’s already available to you; otherwise, all you need to do is
Components.utils.import("resource:///modules/mailServices.js");
The module is available in nightlies and will be part of Thunderbird 3.3 alpha 3 and later.