我想使用雷鸟源代码保存电子邮件附件。我在您的论坛中获得了以下代码..但它不起作用
alert("Messages selected: " + gFolderDisplay.selectedCount);
let enumerator = gFolderDisplay.selectedMessages;
for each (let msgHdr in fixIterator(enumerator, Ci.nsIMsgDBHdr)) {
var messageID = msgHdr.messageId;
alert("MessageID: " + messageID);
var subject = msgHdr.mime2DecodedSubject;
alert("Subject: " + subject);
MsgHdrToMimeMessage(msgHdr, null, function (aMsgHdr, aMimeMsg) {
try {
alert("Size of the message: " + aMimeMsg.size);
alert("Structure of the message:\n" + aMimeMsg.prettyString(true, undefined, true));
let attachments = aMimeMsg.allUserAttachments || aMimeMsg.allAttachments;
alert("Number of attachments: " + attachments.length);
for (let [index, att] in Iterator(attachments))
{
alert ("URL: " + att.url + " Name: " + att.name);
let ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
let neckoURL = null;
neckoURL = ioService.newURI(att.url, null, null);
neckoURL.QueryInterface(Ci.nsIMsgMessageUrl);
let uri = neckoURL.uri;
let attInfo = new AttachmentInfo(att.contentType, att.url, att.name, uri, att.isExternal);
attInfo.save();
}
} catch (err) {
alert(err);
}
}, true, { examineEncryptedParts: true, });
}
使用上面的代码,我可以浏览选定的消息。但不能保存附件。它显示附件的数量。而且我想为选定的邮件设置我自己的标签。我怎样才能做到这一点?请帮帮我...在此先感谢