Cannot send xls-attachment using the E-Mail

Hi,
I have a problem sending Excel- attachments. That file is generated from a previous node (binary write node) which is stored in a docker container (in the /tmp/) folder.
In the Sending-mail node, I have attached the path hardcoded.
But I receive an E-Mail without attachments.

Anyone an idea?

Thanks!

Best
John

Hey @jolo! Welcome to the n8n family!

A couple of things to take a look at:

  1. Is the Excel file getting generated in the /tmp folder?
  2. At what point in the workflow does it get deleted? (I’m assuming that it is getting deleted because it is in the temporary folder)
  3. If you bypass the Excel generation part of the workflow and manually place a file in the /tmp folder, can you send it as an email attachment?

Also, if you can, please post the flow itself. That way, we can troubleshoot the actual workflow and not what we make up in our heads.

1 Like

Hi @Tephlon,
thank you for you message.

Regarding 1) Yes
Regarding 2) Looking into the container, the file is still there.
Regarding 3) Not sure what you mean but below you’ll find the workflow

{
  "name": "Test",
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "select *\nfrom products"
      },
      "name": "Run Query",
      "type": "n8n-nodes-base.postgres",
      "position": [
        530,
        310
      ],
      "typeVersion": 1,
      "credentials": {
        "postgres": "Postgres"
      }
    },
    {
      "parameters": {
        "operation": "toFile",
        "options": {}
      },
      "name": "Spreadsheet File",
      "type": "n8n-nodes-base.spreadsheetFile",
      "position": [
        680,
        310
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "fileName": "/tmp/test.xls"
      },
      "name": "Write Binary File",
      "type": "n8n-nodes-base.writeBinaryFile",
      "position": [
        830,
        310
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "fromEmail": "[email protected]",
        "toEmail": "[email protected]",
        "subject": "Test",
        "text": "TEst",
        "attachments": "/tmp/test.xls",
        "options": {
          "allowUnauthorizedCerts": false
        }
      },
      "name": "Send Email",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 1,
      "position": [
        980,
        310
      ],
      "credentials": {
        "smtp": "Test SMTP"
      }
    }
  ],
  "connections": {
    "Run Query": {
      "main": [
        [
          {
            "node": "Spreadsheet File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Spreadsheet File": {
      "main": [
        [
          {
            "node": "Write Binary File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start": {
      "main": [
        [
          {
            "node": "Run Query",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Write Binary File": {
      "main": [
        [
          {
            "node": "Send Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {},
  "id": "1"
}
1 Like

There is no need to write the file to your hard drive. You can just use the data directly from the flow. That is actually the only way almost all the nodes (except the Read Binary File Node) expect binary data in n8n and so also the Send Email Node.

Here the workflow how it should work fine:

{
  "nodes": [
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "select *\nfrom products"
      },
      "name": "Run Query",
      "type": "n8n-nodes-base.postgres",
      "position": [
        869,
        417
      ],
      "typeVersion": 1,
      "credentials": {
        "postgres": "Postgres"
      }
    },
    {
      "parameters": {
        "operation": "toFile",
        "options": {}
      },
      "name": "Spreadsheet File",
      "type": "n8n-nodes-base.spreadsheetFile",
      "position": [
        1019,
        417
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "fromEmail": "[email protected]",
        "toEmail": "[email protected]",
        "subject": "Test",
        "text": "TEst",
        "attachments": "data",
        "options": {
          "allowUnauthorizedCerts": false
        }
      },
      "name": "Send Email",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 1,
      "position": [
        1180,
        420
      ],
      "credentials": {
        "smtp": "Test SMTP"
      }
    }
  ],
  "connections": {
    "Run Query": {
      "main": [
        [
          {
            "node": "Spreadsheet File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Spreadsheet File": {
      "main": [
        [
          {
            "node": "Send Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
2 Likes

Hey @jan,

so much appreciated. That works like a charm.

I have used https://www.knime.com/ a lot which is also node-based.
It is mainly for data science but I like the In- and Output port with their description.
Do you know if you plan something similar? I would like to contribute code-wise if so.

Best

Great to hear that it works!

Can you maybe post a picture or explain what exactly you mean? I did Google them and their view but could not find what you are referring to.

Hi @jan,

I hope you can see my gif.
However, on the right side you can see whenever you click on a Node you see a small description. That could maybe also link to workflows etc.

Nevertheless, I just realized that you have a category “Feature Request UI” for that :smiley:
It probably makes sense to put it there.
Thanks for your engagement. Much appreciated!

1 Like

Ah I see. Yes please post it as a feature request. Thanks!