我目前正在开发雷鸟的扩展程序,它需要所有未读邮件中的“已接收”标头。我希望我可以通过与主题相同的方法(如Mozilla教程中的教程)来获取接收到的标头,但是它将无法正常工作。 由于这是我第一次编写JavaScript代码,因此我对每一个有帮助的答案都非常感谢。
function listenup(){
console.log("Listening");
var newMailListener = {
msgAdded: function(aMsgHdr) {
if( !aMsgHdr.isRead ) {
console.log("Got Mail");
var mimeConvert = Components.classes["@mozilla.org/messenger/mimeconverter;1"].getService(Components.interfaces.nsIMimeConverter);
var subject = mimeConvert.decodeMimeHeader(aMsgHdr.subject, null, false, true);
var received = mimeConvert.decodeMimeHeader(aMsgHdr.received, null, false, true);
console.log(subject);
console.log(received);
if (false) {
aMsgHdr.markFlagged(true);
}
}
}
};
function init() {
var notificationService = Components.classes["@mozilla.org/messenger/msgnotificationservice;1"].getService(Components.interfaces.nsIMsgFolderNotificationService);
notificationService.addListener(newMailListener, notificationService.msgAdded);
}
addEventListener("load", init, true);
}