Saving email to disk on TB 60.8

Talk about add-ons and extension development.
Posts: 3
Joined: January 23rd, 2019, 12:31 am

Post Posted August 12th, 2019, 7:50 am

Hello all!

I have a ThunderBird extention that saving email to disk. It using function SaveMessageToDisk and before all was OK.
As i remember on version TB 60.4 it worked fine, but on TB 60.8 all incoming letters automatically marked as read by this function.

I try to write saving to disk by myself. I try example from here:
Code: Select all
var content = "";
  var MessageURI = GetFirstSelectedMessage();
  var MsgService = messenger.messageServiceFromURI(MessageURI);
  var MsgStream =  Components.classes[";1"].createInstance();
  var consumer = MsgStream.QueryInterface(Components.interfaces.nsIInputStream);
  var ScriptInput = Components.classes[";1"].createInstance();
  var ScriptInputStream = ScriptInput.QueryInterface(Components.interfaces.nsIScriptableInputStream);
  try {
    MsgService.streamMessage(MessageURI, MsgStream, msgWindow, null, false, null);
  } catch (ex) {
    alert("error: "+ex)
  while (ScriptInputStream.available()) {
    content = content +;

But on line «ScriptInputStream.available()» it is stopped and no execute after tis line. Sometimes after about ten minutes TB crushed.
Just for test i tryed use only «» — same result.

Then i found topic: and use example with function getMsgTextFromStream:
Code: Select all
var msgHdr = gFolderDisplay.selectedMessage;
var msgUri = msgHdr.folder.getUriForMsg(msgHdr);
var messenger = Components.classes[";1"].
var msgService = messenger.messageServiceFromURI(msgUri);
var syncStreamListener = Components.classes[";1"].
msgService.streamMessage(msgUri, syncStreamListener, null, null, false, "", true);
var contentType = new Object();
var data = msgHdr.folder.getMsgTextFromStream(
  syncStreamListener.inputStream, msgHdr.Charset, 65536, 32768, false, true, contentType);

And again — on line with getMsgTextFromStream function it stopped and sometimes crashed after few minutes.

So, i have two questions:
1) Is there any way to use the function SaveMessageToDisk so that it doesn't mark emails as read?
2) If not — how to make the way with the functions streamMessage or getMsgTextFromStream work?


User avatar
Posts: 45550
Joined: July 30th, 2003, 5:06 pm

Post Posted August 26th, 2019, 5:23 pm

Thunderbird 68.0 will be out soon. Right now its undergoing smoke testing. They will try to retain support for legacy add-ons (though you will need to make some changes) but its very webextension-centric. I suggest you look at the source code for "ImportExportTools NG", the webextension based replacement for the ImportExportTools add-on. That add-on imports/exports mail to mbox files.

I suggest you read and then .

Return to Extension Development

Who is online

Users browsing this forum: No registered users and 1 guest