Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Thunderbird: Accessing mail body in plain text

5 views
Skip to first unread message

Sebastian Kirsche

unread,
Apr 30, 2007, 11:37:37 AM4/30/07
to
Hi, I'm trying to extract the body of a mail in plain text. Like when
you use "File->Save As->File", and select "Text Files" as file type.
But without showing the dialog.

Thanks to the tip under the following URL, I'm able to read the body
in some special HTML format:
http://code.google.com/p/colorediffs/wiki/HowToGetMessageTextInThunderbird

The file nsMessenger.cpp suggests using ConvertBufToPlainText() to
convert it to plain text. I started looking for a JavaScript
accessible equivalent and found the following snippet. It works fine
in Firefox, but fails at the second line in Thunderbird.

var unescapeHTMLTemp = Components.classes["@mozilla.org/feed-
unescapehtml;1"];
var unescapeHTML =
unescapeHTMLTemp.getService(Components.interfaces.nsIScriptableUnescapeHTML);
alert(unescapeHTML.unescape("<ul><li><b>Hello</b></li><li>World<li></
ul>"));

Do you have an idea how to get it working in Thunderbird? I'd be happy
for any hint.

Thanks

Sebastian Kirsche

unread,
May 1, 2007, 8:58:15 AM5/1/07
to
On 30 Apr., 17:37, Sebastian Kirsche <sebastian.kirs...@gmail.com>
wrote:

> var unescapeHTMLTemp = Components.classes["@mozilla.org/feed-
> unescapehtml;1"];
> var unescapeHTML =
> unescapeHTMLTemp.getService(Components.interfaces.nsIScriptableUnescapeHTML);
> alert(unescapeHTML.unescape("<ul><li><b>Hello</b></li><li>World<li></
> ul>"));

After playing with these lines a bit more, I discovered that it works
just fine in Thunderbird 2.0.0.0 for GNU/Linux and Mac OS X. Under
Windows (XP), it works in Firefox 2.0.0.3, but doesn't work in
Thunderbird 2.0.0.0.

The JavaScript error at the second statement is:
Error: uncaught exception: [Exception... "Invalid InterfaceID"
nsresult: "0x80570018 (NS_ERROR_XPC_BAD_IID)"

Is this a bug in Thunderbird?

Philip Chee

unread,
May 2, 2007, 4:40:24 AM5/2/07
to
On 1 May 2007 05:58:15 -0700, Sebastian Kirsche wrote:

> After playing with these lines a bit more, I discovered that it works
> just fine in Thunderbird 2.0.0.0 for GNU/Linux and Mac OS X. Under
> Windows (XP), it works in Firefox 2.0.0.3, but doesn't work in
> Thunderbird 2.0.0.0.

> The JavaScript error at the second statement is:
> Error: uncaught exception: [Exception... "Invalid InterfaceID"
> nsresult: "0x80570018 (NS_ERROR_XPC_BAD_IID)"

> Is this a bug in Thunderbird?

("nsIScriptableUnescapeHTML" in Components.interfaces)
returns true in Firefox 2.0 but false in Thunderbird 2.0. Possibly a
build bug.

Phil
--
Philip Chee <phi...@aleytys.pc.my>, <phili...@gmail.com>
http://flashblock.mozdev.org/ http://xsidebar.mozdev.org
Guard us from the she-wolf and the wolf, and guard us from the thief,
oh Night, and so be good for us to pass.
[ ]We secretly replaced the dilithium with Folger's Crystals
* TagZilla 0.059.4

Sebastian Kirsche

unread,
May 2, 2007, 10:07:05 AM5/2/07
to
0 new messages