Open Evgeny- opened 9 years ago
Hi Evgeny,
I've facing same problem. Unable to download attachments from mail. using your approach only blank file with 0 kb downloaded. Please help
Thanks
Hi Gaurav,
I have using options like this:
{
...,
mailParserOptions: {streamAttachments: false},
attachments: false,
attachmentOptions: { directory: "attachments/" }
}
And then saving attachments directly:
mail.on("mail", function(mail, seqno, attributes) {
if(mail.attachments && mail.attachments.length) {
var attach = mail.attachments[0];
fs.writeFile('file', attach.content, function(err) {
// callback
});
}
});
I hope this will help
If you are using
{streamAttachments: true}
for the mailParserOptions, then you will get the stream of the attachment without file buffer. So then you cannot save the attachment withfs.writeStream
, and must useattachment.stream.pipe(filename)
as in the mailparser documentation (not work for me, actually). So may be solution is do not use{streamAttachments: true}
in documentation.Thanks