Saving attachment fail
Opened this issue · 2 comments
Evgeny- commented
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 with fs.writeStream
, and must use attachment.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
gaurav341 commented
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
Evgeny- commented
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