Question

I already created an extension that does the following:

When I run Thinderbird with the command line thunderbird -MyCustomParam1 "12345" my extension will open a compose window and add the parameter "12345" to the window.

Some code that I use:

// In the calling code
var args = {
  param1: 12345,

};

args.wrappedJSObject = args;
var watcher = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
                            .getService(Components.interfaces.nsIWindowWatcher);
watcher.openWindow(null, url, windowName, features, args);


// In the window code
var args = window.arguments[0].wrappedJSObject;

Of course using the correct url and features.

Now I want to do the same, but for the message window and with am eml file that is choose.

You can open an eml file from the command line like this: Thunderbird test.eml (this will open the mail in a new window).

What I want is the following:

Thunderbird test.eml -MycustomParam1 "1234" should open the mail, and add the param "1234" to screen, so I can access it in the document window, just like example 1.

So basically I want something like watcher.openWindow, but with a given eml file.

Any ideas?

Was it helpful?

Solution

You can see how this is done in the MsgOpenFromFile function, it is being called for the File / Open Saved Message menu item. You basically have to take the eml file (get an nsIFile instance from file path), turn it into a URI and then change the query string before opening a message window:

uri.QueryInterface(Components.interfaces.nsIURL);
uri.query = "type=application/x-message-display";
watcher.openWindow(null, "chrome://messenger/content/messageWindow.xul", "_blank",
                   "all,chrome,dialog=no,status,toolbar", uri);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top