2012-06-11 26 views
0

我已經創建了執行以下操作的擴展:Thunderbid擴展:開放EML文件

當我運行Thinderbird使用命令行thunderbird -MyCustomParam1 "12345"我的分機將打開一個撰寫窗口和參數"12345"添加到窗口。

一些代碼,我使用:

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

當然使用正確的URL和功能。

現在我想要做同樣的事情,但對於消息窗口和eml文件是選擇。

您可以從命令行打開eml文件,如下所示:Thunderbird test.eml(這將在新窗口中打開郵件)。

我想是這樣的:

Thunderbird test.eml -MycustomParam1 "1234"應該打開郵件,並添加帕拉姆"1234"篩選,這樣我就可以訪問它在文檔窗口,就像例1

所以基本上我想要像watcher.openWindow,但與給定的eml文件。

任何想法?

回答

0

您可以在MsgOpenFromFile function中看到這是如何完成的,它正在被調用File/Open Saved Message菜單項。基本上,你必須採取eml文件(get an nsIFile instance from file path),turn it into a URI,然後打開一個消息窗口前更改查詢字符串:

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

謝謝。它的工作正常 – user1449511

+0

這工作正常。但是,當我有一個HTML郵件,它打印郵件爲純文本。有沒有辦法在打開文件時指定它的HTML郵件? – user1449511

+0

上述評論中的問題的答案:https://stackoverflow.com/questions/27689496/opening-and-printing-a-thunderbird-html-file/27690687#27690687 – user1449511