Hi,
I am using Email.send() for sending excel file with attachments. But getting unable to open attachment in email ->
Email.send({
to: email,
from: "xxx@gmail.com",
subject: "Report ",
text:'Text',
attachments: [
{
filename: "report.xlsx",
contents: file,
encoding: 'binary',
contentType: 'application/octet-stream',
contentTransferEncoding: 'base64'
}
]
});
Where as in mailcomposer with nodemailer, it works perfectly. ->
var nodemailer = Meteor.npmRequire("nodemailer");
var transporter = nodemailer.createTransport([smtp]);
var cid_value = Date.now() + '.image.jpg';
var mailcomposer = Meteor.npmRequire("mailcomposer");
var mailOptions = {
rejectUnhauthorized : false,
from: "xxx@gmail.com",
to: email,
subject: "Report",
html: html,
attachments: [
{
filename: "report.xlsx",
content: file,
encoding: 'binary',
contentType: 'application/octet-stream',
contentTransferEncoding: 'base64'
}
]
}
var mail = mailcomposer(mailOptions);
var stream = mail.createReadStream();
stream.pipe(process.stdout);
mail.build(function(err, message){
process.stdout.write(message);
});
transporter.sendMail(mailOptions, function(error, info){
if(error){
return console.log(error);
}
console.log('Mail sent: ', info);
});
}
How to send it correctly