据我所知,您无法访问整个正文(使用邮件和 html 标签)。您拥有 XPCOM 脚本接口nsIMsgDbHdr的功能和属性。我有一个发送邮件的插件。我在以下代码片段的帮助下阅读了整个邮件正文。如您所见,我从磁盘读取了整封邮件并将其内容加载到变量中。您还可以使用它来阅读完整的邮件正文。
function SendMailNow(aMsgDBHdr) {
var aMsgURI = aMsgDBHdr.folder.getUriForMsg(aMsgDBHdr);
var msgWindow = Components.classes["@mozilla.org/messenger/msgwindow;1"]
.createInstance();
msgWindow = msgWindow.QueryInterface(Components.interfaces.nsIMsgWindow);
var msgStream = Components.classes["@mozilla.org/network/sync-stream-listener;1"]
.createInstance();
msgStream = msgStream.QueryInterface(Components.interfaces.nsIInputStream);
var aMsgService = messenger.messageServiceFromURI(aMsgURI);
var scriptInputStream = Components.classes["@mozilla.org/scriptableinputstream;1"]
.createInstance();
scriptInputStream = scriptInputStream
.QueryInterface(Components.interfaces.nsIScriptableInputStream);
scriptInputStream.init(msgStream);
try {
aMsgService.streamMessage(aMsgURI, // uri of message to stream
msgStream, // a stream listener listening to the message
msgWindow, // a nsIMsgWindow for progress and status feedback
null, // a nsIUrlListener that is notified when url starts and stops
false, // it will create a stream converter from message rfc2822 to
null // Header added to the URI. e.g., header=filter
);
} catch (ex) {
}
// Creating content
var content = "";
while (scriptInputStream.available()) {
content = content + scriptInputStream.read(512);
if (content.match(/\r\n\r\n/) || content.match(/\n\n/)) {
if (sendMail(content, aMsgDBHdr.messageId)) {
log("SEND_DONE\t" + aMsgDBHdr.messageId + "\t"
+ aMsgDBHdr.subject);
} else {
log("SEND_FAILED\t" + aMsgDBHdr.messageId + "\t"
+ aMsgDBHdr.subject);
}
}
}
}
我希望这能帮到您!