1
0
mirror of https://github.com/node-red/node-red-nodes.git synced 2023-10-10 13:36:58 +02:00

email node - put description before attached file.

This commit is contained in:
Dave Conway-Jones 2017-04-03 18:02:17 +01:00
parent d86cf60b06
commit 47520ea5aa
3 changed files with 6 additions and 8 deletions

View File

@ -90,12 +90,13 @@ module.exports = function(RED) {
if ((msg.payload[0] === 0x89)&&(msg.payload[1] === 0x50)) { fe = "png"; } //4E if ((msg.payload[0] === 0x89)&&(msg.payload[1] === 0x50)) { fe = "png"; } //4E
msg.filename = "attachment."+fe; msg.filename = "attachment."+fe;
} }
sendopts.attachments = [ { content: msg.payload, filename:(msg.filename.replace(/^.*[\\\/]/, '') || "file.bin") } ]; var fname = msg.filename.replace(/^.*[\\\/]/, '') || "file.bin";
sendopts.attachments = [ { content:msg.payload, filename:fname } ];
if (msg.hasOwnProperty("headers") && msg.headers.hasOwnProperty("content-type")) { if (msg.hasOwnProperty("headers") && msg.headers.hasOwnProperty("content-type")) {
sendopts.attachments[0].contentType = msg.headers["content-type"]; sendopts.attachments[0].contentType = msg.headers["content-type"];
} }
// Create some body text.. // Create some body text..
sendopts.text = RED._("email.default-message",{filename:(msg.filename.replace(/^.*[\\\/]/, '') || "file.bin"),description:(msg.hasOwnProperty("description") ? "\n\n"+msg.description : "")}); sendopts.text = RED._("email.default-message",{filename:fname, description:(msg.description||"")});
} }
else { else {
var payload = RED.util.ensureString(msg.payload); var payload = RED.util.ensureString(msg.payload);

View File

@ -13,10 +13,7 @@
"useSSL": "Use SSL?", "useSSL": "Use SSL?",
"disposition": "Disposition" "disposition": "Disposition"
}, },
"default-message": "__description__\n\nFile from Node-RED is attached: __filename__",
"default-message": "Your file from Node-RED is attached: __filename__ __description__",
"tip": { "tip": {
"cred": "<b>Note:</b> Copied credentials from global emailkeys.js file.", "cred": "<b>Note:</b> Copied credentials from global emailkeys.js file.",
"recent": "Tip: Only retrieves the single most recent email." "recent": "Tip: Only retrieves the single most recent email."

View File

@ -1,6 +1,6 @@
{ {
"name": "node-red-node-email", "name": "node-red-node-email",
"version": "0.1.21", "version": "0.1.22",
"description": "Node-RED nodes to send and receive simple emails", "description": "Node-RED nodes to send and receive simple emails",
"dependencies": { "dependencies": {
"nodemailer": "^1.11.0", "nodemailer": "^1.11.0",