Hi,
for downloading the attachments i wrote following piece of code. This is working perfectly fine
But thing is i want to append from email id at the end of each attachment file name at the time of downloading.Something like "attachment.generatedFileName+'___'+fromemailid ". But i am not able to get from email id or even mail object in the attachments event.
Also i thought like as mail processing is sequential, i thought of taking a variable called fromEmail and fill it with the actual value in
mailListener.on("mail", function(mail, seqno, attributes){})
and later make use of it in attachments event. But thing is attachments event is firing first and later mail event is firing.
mailListener.on("attachment", function(attachment){
var validDownloadTypes=['application/pdf','application/msword','text/plain','application/rar','application/zip'];
if(validDownloadTypes.indexOf(attachment.contentType)>=0)
{
console.log("Downloading attachment to --- C:\MailDownloads\"+attachment.generatedFileName);
var output = fs.createWriteStream("C:\MailDownloads\"+attachment.generatedFileName);
attachment.stream.pipe(output);
}
});
Hi, for downloading the attachments i wrote following piece of code. This is working perfectly fine But thing is i want to append from email id at the end of each attachment file name at the time of downloading.Something like "attachment.generatedFileName+'___'+fromemailid ". But i am not able to get from email id or even mail object in the attachments event.
Also i thought like as mail processing is sequential, i thought of taking a variable called fromEmail and fill it with the actual value in mailListener.on("mail", function(mail, seqno, attributes){})
and later make use of it in attachments event. But thing is attachments event is firing first and later mail event is firing.
mailListener.on("attachment", function(attachment){ var validDownloadTypes=['application/pdf','application/msword','text/plain','application/rar','application/zip']; if(validDownloadTypes.indexOf(attachment.contentType)>=0) { console.log("Downloading attachment to --- C:\MailDownloads\"+attachment.generatedFileName); var output = fs.createWriteStream("C:\MailDownloads\"+attachment.generatedFileName); attachment.stream.pipe(output); } });