Issues with .eml from gmail

Describe the problem/error/question

Hello, I have a Read email cron task that runs every 2 minutes and reads and adds all the emails to our database and each attachment. Everything working perfect.

My only issue right now is with the .eml files (but not sure) if this could be an issue with other files.

Simply, my download attachment action is indeed downloading the “binary” file but not usable, it’s just empty for the next nodes:

Check to detect if there are any attachments to upload to my S3:

Any ideas why is this happening? With other attachment it works fine…

And normally when I get an attachment it shows two buttons “Show” and “Download” which is not doing in this case…

What is the error message (if any)?

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 1.11.1
  • Database (default: SQLite): Postgressql
  • n8n EXECUTIONS_PROCESS setting (default: own, main): queue
  • Running n8n via (Docker, npm, n8n cloud, desktop app): docker image
  • Operating system: railway/linux

Hey @yukyo,

It looks like the eml file has no filename which makes sense as sometimes they don’t, What you could do is filter them out similar to what you are doing and maybe set a filename for it using a set node assuming it is always going to be attachment_0

Althought the s3 node has a filename field so you could maybe try setting one in there to see if that works.

Hi @Jon . That’s odd because the file has a filename:

(gmail inbox)

However, I made this script to give it a name if it doesn’t have one, but doesn’t seem to make any difference:

let results = [];
let index = 0; // index

function generateUniqueString() {
    return `unnamed_${}_${index}_${Math.random().toString(36).substr(2, 9)}`;

for (item of items) {
    for (key of Object.keys(item.binary)) {
        let baseName, extension;

        // If fileName exists
        if (item.binary[key].fileName) {
            // Extract the filename and extension
            let parts = item.binary[key].fileName.split('.');
            baseName = parts.slice(0, -1).join('.');
            extension = parts[parts.length - 1];
        } else {
            // Generate a unique base name and get the extension from fileExtension
            baseName = generateUniqueString();
            extension = item.binary[key].fileExtension || 'bin'; // Using 'bin' as a fallback in case fileExtension is also missing

        let uniqueFileName = `${baseName}.${extension}`; // No need to append index here since we're generating a unique base name

            json: {
                fileName: uniqueFileName
            binary: {
                data: item.binary[key],
        index++; // Increment the index for the next filename

return results;


Hey @yukyo,

That is odd, What happens when you try to upload it to s3?

Nothing because uploading to S3 requires a filename, which in this case I can’t access to.

I guess you mean trying to upload the file directly with a static name, I think that won’t work for my usecase as I “download” all the attachments and run the above script to put them a name if they don’t have one, and I use each binary.fileName to upload them to S3.

Hey @yukyo,

So when you give the binary item a name did that not work either? I would expect that to work as it would have a name.

@Jon Nope, still doesn’t work.

Always binary items give me the option to “Download” or “View” in the editor… but not for this file

Hey @yukyo,

There is no filename on the binary item still so I suspect the code in the function node you are using might need to be updated.

I don’t understand why in the first place the name isn’t there when It should, as the file has a name, you can see that in the gmail inbox screenshot, but my script should add a name, but it’s still not working…

Hey @yukyo,

I am not sure on that either, I will need to create an eml file to test with properly. Looking at the output of your code node it isn’t adding a name which is also strange. I will set aside some time on Monday morning to test this.

Hi @Jon did you have a chance to test this out? Not urgent, just following up. I don’t get .eml files very often, but I would like to get a workaround for this.


Hey @yukyo,

I did get a chance to take a look and oddly for me an eml file loaded with the filename as expected.

Do you get this issue with all email files or just certain ones.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.