Useful code snippet: getting the headers of an email (nsIMsgDBHdr)

Guenter Wahl neandr at
Thu Nov 10 10:28:00 UTC 2011

Hi Jonathan,

once more EXCELLENT, thanks.

One question: you say ".. a function on top of that .." on top of Davids code which is for TB10. But you also say your code runs for older TB versions. So, I'm confused .. does your code work with TB6/7 as well?

-------- Original-Nachricht --------
> Datum: Thu, 10 Nov 2011 10:26:51 +0100
> Von: Jonathan Protzenko <jonathan.protzenko at>
> An: tb-planning at, dev-apps-thunderbird at, dev-extensions at
> Betreff: Useful code snippet: getting the headers of an email (nsIMsgDBHdr)

> Hi all,
> I'm posting this here in the hope that it's useful to other addon 
> developers, and that it shows up in search results.
> Recently (Thunderbird 10), David Bienvenu kindly implemented a new 
> function that allows one to quickly grab the headers part of a given 
> message body. This is very useful: if the message has attachments, we 
> won't be downloading the entire body just to get the headers.
> I wrote a function on top of that that does the dirty work to *get the 
> MIME headers of an email* in Thunderbird. It provides a nice API on top 
> of David's function, and is also able to work with older versions of 
> Thunderbird.
> (I'm not copy/pasting the whole code here because there's a stream 
> listener involved and some other stuff. As usual, you can grab my 
> thunderbird-stdlib project to use the function right away.)
> *Here's how you use it:*
>     msgHdrGetHeaders(gFolderDisplay.selectedMessage, function (aHeaders) {
>        if (aHeaders.has("reply-to"))
>          dump("This message has a reply-to header; its value is
>     "+aHeaders.get("reply-to")+"\n");
>     });
> This allows you to get the headers of any message (not just the one 
> that's displayed, like in the example). It's particularly useful when 
> you have an nsIMsgDBHdr, and you want to inspect it.
> Let me know if you have any suggestions / bug reports / ideas :)
> Cheers,
> jonathan

NEU: FreePhone - 0ct/min Handyspartarif mit Geld-zurück-Garantie!		
Jetzt informieren:

More information about the tb-planning mailing list