2

I want to send mail from nodemailer that attaches .xlsx that written from excel4node libs. I don't know how to do it but I can do both things solely.

I have tried writing the file and store as temp then bring the file up again but firebase pop-up the error Error: EROFS: read-only file system, open

I really have no idea how to do it please help. thank in advance.

2 Answers2

1

I got it!!!. using writing buffer from excel4node and then send them to the content of attachment

1
const xl = require('excel4node');

async sendMail(data) {
var wb = new xl.Workbook();
var ws = wb.addWorksheet('SHEET_NAME');
ws.cell(1, 1).string('ALL YOUR EXCEL SHEET FILE CONTENT');
let buffer_xlsx = await wb.writeToBuffer();


// in the option header of nodeMailer
header: {
    from: 'abc@example.com',
    to: 'xyz@example.com',
    subject: 'Excel File',
    attachments = [
    {
        filename: 'report_' + filename + '.xlsx',
        content: buffer_xlsx,
    }]
}
  • Thank you for the code. This is the exact code for the solution, which I commented below. I have lost that piece of code. So I didn't uploaded it. Thank you again for your contribution!. – Natthapol Maneechote Jan 05 '22 at 13:53