如何在雷鸟中通过IMAP下载消息到本地计算机
How to download a message to the local computer via IMAP in Thunderbird?
我通过gloda模块函数MsgHdrToMimeMessage
接收附件
MsgHdrToMimeMessage(msgHdr, null, function(aMsgHdr, aMimeMsg) {
let attachments = aMimeMsg.parts[0].parts;
log(attachments);
}, false, {
saneBodySize: false,
});
如何使用(imap://)链接将消息本地下载到计算机上?
我试着用这个。但是我有错误。
MsgHdrToMimeMessage(msgHdr, null, function(aMsgHdr, aMimeMsg) {
try {
var attachments = aMimeMsg.allAttachments;
for (var [index, att] in Iterator(attachments)) {
var ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
var attURL = null;
attURL = ioService.newURI(att.url, null, null);
attURL.QueryInterface(Ci.nsIMsgMessageUrl);
log(attURL)
var uri = attURL.uri;
// not work in this place.
// console.log: ReferenceError {}
var file = FileUtils.getFile("TmpD", [att.name]);
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, FileUtils.PERMS_FILE);
messenger.saveAttachmentToFile(file, att.url, uri, att.contentType, null);
}
} catch (err) {
log(err);
}
}, false, {
saneBodySize: false,
});
问题解决。从服务器下载附件的实现:
// Initialize.
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
Cu.import("resource:///modules/mailServices.js");
Cu.import("resource:///modules/iteratorUtils.jsm");
Cu.import("resource:///modules/Services.jsm");
Cu.import("resource:///modules/gloda/mimemsg.js");
Cu.import("resource:///modules/FileUtils.jsm");
MsgHdrToMimeMessage(msgHdr, null, function(aMsgHdr, aMimeMsg) {
let attachments = aMimeMsg.allAttachments;
for (let [index, att] in Iterator(attachments)) {
let ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
let attURL = ioService.newURI(att.url, null, null);
attURL.QueryInterface(Ci.nsIMsgMessageUrl);
let uri = attURL.uri;
let file = FileUtils.getFile("TmpD", [att.name]);
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, FileUtils.PERMS_FILE);
let messenger = Cc["@mozilla.org/messenger;1"].createInstance(Ci.nsIMessenger);
messenger.saveAttachmentToFile(file, att.url, uri, att.contentType, null);
}
}, false, {});
相关文章:
- Ajax聊天消息重复而不仅仅是更新
- 如果localstorage为空,则显示欢迎消息
- 无法在本地计算机中将画布另存为图像
- 绑定时将Parsley minlength消息作为选项传递时,未对其进行自定义
- 离开页面时弹出消息
- 有没有一种方法可以在控制台关闭的情况下让console.log()在IE中记录消息
- 消息显示之外的淘汰验证
- 选项卡侦听器未被来自后台脚本的消息激活
- jquery如何从计算机添加图像
- jQuery在输入下验证post错误消息
- Scipt未在选定选项卡中执行以发送和接收消息
- 检查xmlhttprequest问题的消息
- AngularJs对ng消息的自定义替换
- ng消息仅在触摸时显示错误,并在错误的初始显示上转换
- 当用户按下回车键时,自动在text区域/text中插入消息
- 如果消息框答案为YES,则用Javascript填写表单
- 在javaservlet doPost方法中启动线程时,无法返回异常消息
- 解析云代码错误:解析.错误{代码:141,消息:“未调用成功/错误”}
- Node.js上的WebSocket,并在所有连接的客户端之间共享消息
- 如何在雷鸟中通过IMAP下载消息到本地计算机