While sending email notification using smtp method can i send list of records as attachement in that mail. Is it possible if yes how ?
Hello, this is not supported.
@Mohanakanna-iopex, @hongboji is right that the SMTP notification channel can’t attach a list of records. There are still two workable routes with built-in workflow nodes.
1. Put the list in the email body (no attachment needed)
Trigger → Query Data (Result type: Multiple Records, plus your filter, sort and pagination) → JavaScript node → Send email node (content type HTML).
In the JavaScript node add a parameter rows set to the Query Data result, then return an HTML table. This runs in the default safe sandbox, no modules needed:
const cols = ['id', 'title', 'status']; // your field names
const esc = (v) => String(v ?? '').replace(/[&<>"]/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
const head = cols.map((c) => `<th>${esc(c)}</th>`).join('');
const body = rows.map((r) => `<tr>${cols.map((c) => `<td>${esc(r[c])}</td>`).join('')}</tr>`).join('');
return `<table border="1" cellpadding="4"><tr>${head}</tr>${body}</table>`;
Use the JavaScript node’s result as the email content. The Send email node takes the same SMTP host, port and credentials you already use.
2. A real file attachment
Since v2.1.5 the workflow Send email node has an Attachments setting, but it only accepts file records (a file collection record or an attachment field), not a query result or generated text. So if the files already live in NocoBase, upgrade and pick them there.
For a generated CSV of the records, send through your mail provider’s HTTP API instead of SMTP (most accept attachments as base64 in JSON):
- Query Data as above.
- JavaScript node builds the CSV and base64 encodes it.
Bufferis not available in safe mode, so setWORKFLOW_SCRIPT_MODULES=bufferon the server and restart:
const { Buffer } = require('buffer');
const cols = ['id', 'title', 'status'];
const q = (v) => `"${String(v ?? '').replace(/"/g, '""')}"`;
const csv = [cols.join(','), ...rows.map((r) => cols.map((c) => q(r[c])).join(','))].join('\n');
return Buffer.from(csv, 'utf8').toString('base64');
- HTTP Request node, POST
application/jsonto the provider’s send endpoint, with the result inside a JSON string, e.g."content": "{{ JavaScript node result }}"and a filename likerecords.csv. Field names differ per provider, so check its send API docs.
If it has to be a PDF, add an HTTP Request node before step 3 that posts the HTML table from route 1 to an HTML to PDF renderer that returns base64, and pass that on instead of the CSV.
(Disclosure: I’m connected to thirds.ai.)