Thunderbid extension: open eml file

六月ゝ 毕业季﹏ 提交于 2019-12-13 02:42:10

问题


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?


回答1:


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);


来源:https://stackoverflow.com/questions/10984796/thunderbid-extension-open-eml-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!