我需要在Thunderbird扩展程序中获取一些电子邮件数据。我在MDN(https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsIMsgMessageService)上找到了这个例子:
var content = "";
var MessageURI = GetFirstSelectedMessage();
var MsgService = messenger.messageServiceFromURI(MessageURI);
var MsgStream = Components.classes["@mozilla.org/network/sync-stream-listener;1"].createInstance();
var consumer = MsgStream.QueryInterface(Components.interfaces.nsIInputStream);
var ScriptInput = Components.classes["@mozilla.org/scriptableinputstream;1"].createInstance();
var ScriptInputStream = ScriptInput.QueryInterface(Components.interfaces.nsIScriptableInputStream);
ScriptInputStream.init(consumer);
try {
MsgService.streamMessage(MessageURI, MsgStream, msgWindow, null, false, null);
} catch (ex) {
alert("error: "+ex)
}
ScriptInputStream .available();
while (ScriptInputStream .available()) {
content = content + ScriptInputStream .read(512);
}
alert(content);
然而,当我运行它时,我收到以下错误:
Timestamp: 2013.06.21. 14:47:21
Error: ReferenceError: GetFirstSelectedMessage is not defined
Source File: chrome://edus_extension/content/messengerOverlay.js
Line: 90
这是什么'GetFirstSelectedMessage'函数,如何在不使用它的情况下获取消息URI?
答案 0 :(得分:2)
此文档看起来已经过时了。我建议:
gFolderDisplay.selectedMessage
(尝试在错误控制台中输入top.opener.gFolderDisplay.selectedMessage
),Services
和MailServices
的代码,以简化您的代码。话虽如此,我不知道你想要达到的目的但是:
MsgHdrToMimeMessage
(自我引用:http://blog.xulforum.org/index.php?post/2011/01/03/An-overview-of-Thunderbird-Conversations)祝你好运,一旦你得到一份工作样本,请把它添加到MDN维基!
干杯,
乔纳森