我正在研究MEAN堆栈中的项目,我必须将附件下载到电子邮件地址并将其保存到DB。 为此,我使用download-email-attachments成功下载指定时间的电子邮件。 现在问题是我需要在下载所有文件后运行另一个代码来保存文件,但我无法获得下载 - 电子邮件附件中下载的文件的任何端点。我尝试添加一个onEnd函数,该函数在文件下载开始之前运行。这是我的代码:
// Attachment Download
var onEnd = function (result) {
if (result.error) {
console.log(result.error)
return
}
console.log("Result:")
console.log(result);
if (undefined == result.latestTime) {
}
}
var downloadEmailAttachments = require('download-email-attachments');
downloadEmailAttachments({
account: '"email@gmail.com":password@imap.gmail.com:993',
directory: 'files/',
filenameFilter: /.zip?$/,
timeout: 2000,
log: {warn: console.warn, debug: console.info, error: console.error, info: console.info },
since: '2018-02-14',
attachmentHandler: function (attachmentData, cbfun, errorCB) {
console.log(attachmentData)
cbfun()
}
}, onEnd);
// Attachment Download End
任何帮助将不胜感激。 感谢