How to forward an attachment from a Gmail

Describe the problem/error/question

As a first step to a more complex workflow I want to simply be able to:
set a trigger when I label a gmail (fine)
test whether that email has a pdf attachment (fine)
send a gmail to a new mailbox with the attachment attached (problem).

What is the error message (if any)?

The item has no binary field ‘data’ [item 0] (item 0)

I have tried all the help articles for different ways of trying to link to the attachment.

Please share your workflow

Share the output returned by the last node

Information on your n8n setup.

All defaults. Running on MacOS via Chrome

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:
1 Like
  • n8n version: - Web
  • Database (default: SQLite): - default
  • n8n EXECUTIONS_PROCESS setting (default: own, main): - default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): - n8n cloud
  • Operating system: - MacOS Sonoma 14.6.1 / Chrome 132.0.6834.160

You’ll need to actually download the binary data using an HTTP request node first:

Adding more detail

This works fine:

This also works fine

But when I hook things up:

it stops working.
I get this error message

image

It is the same if I hook things up in series

In the parallel and series case I have the same settings for the gmail node as I had when it was all working.

And the binary is clearly there as an input

If I just delete the link from information extractor to Gmail, it works again.

I want to be able to do some processing / extraction steps on the email and then send that, along with the attachment, onwards. I cannot solve this!

Any help gratefully received.

Here is the code of the version that is not working.

{
  "name": "Test posting attachments",
  "nodes": [
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "simple": false,
        "filters": {
          "labelIds": [
            "Label_7413587365285494846"
          ]
        },
        "options": {
          "dataPropertyAttachmentsPrefixName": "attachment_",
          "downloadAttachments": true
        }
      },
      "type": "n8n-nodes-base.gmailTrigger",
      "typeVersion": 1.2,
      "position": [
        -300,
        0
      ],
      "id": "97b37ae3-61f7-44e5-8739-dbb4831207e7",
      "name": "GmailTrigger",
      "credentials": {
        "gmailOAuth2": {
          "id": "zhoNqeTTPqqwDJTA",
          "name": "Gmail account 3"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "7133b422-4566-41ce-8f29-dd730c72b55e",
              "leftValue": "={{\n  $node[\"GmailTrigger\"].binary !== undefined && \n  Object.keys($node[\"GmailTrigger\"].binary).some(key => \n    $node[\"GmailTrigger\"].binary[key].mimeType === \"application/pdf\" ||\n    $node[\"GmailTrigger\"].binary[key].fileName.toLowerCase().endsWith('.pdf')\n  )\n}}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -80,
        0
      ],
      "id": "f53d8a4f-4b5f-4319-a2fd-5b42111c7f5b",
      "name": "Check for pdf"
    },
    {
      "parameters": {
        "sendTo": "[email protected]",
        "subject": "Attachment enclosed",
        "message": "See attachment",
        "options": {
          "attachmentsUi": {
            "attachmentsBinary": [
              {
                "property": "=attachment_0"
              }
            ]
          }
        }
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        420,
        -20
      ],
      "id": "42edba13-c0a8-400f-8a12-f23479a4490e",
      "name": "Gmail",
      "webhookId": "3327f39c-7cc7-436c-b2ba-fbefa9ff3dc4",
      "credentials": {
        "gmailOAuth2": {
          "id": "zhoNqeTTPqqwDJTA",
          "name": "Gmail account 3"
        }
      }
    },
    {
      "parameters": {
        "text": "={{ $json.text }}",
        "attributes": {
          "attributes": [
            {
              "name": "company_name",
              "description": "the name of the company that the update concerns",
              "required": true
            }
          ]
        },
        "options": {
          "systemPromptTemplate": "You are an expert extraction algorithm.\nOnly extract relevant information from the text.\nIf you do not know the value of an attribute asked to extract, you may omit the attribute's value."
        }
      },
      "type": "@n8n/n8n-nodes-langchain.informationExtractor",
      "typeVersion": 1,
      "position": [
        80,
        -240
      ],
      "id": "60c50fc0-6509-49ce-88f3-48b99e70f173",
      "name": "Information Extractor"
    },
    {
      "parameters": {
        "model": "claude-3-5-sonnet-20241022",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "typeVersion": 1.2,
      "position": [
        180,
        -100
      ],
      "id": "847e7b9d-1d67-48a5-ab49-d20bff332fe3",
      "name": "Anthropic Chat Model",
      "credentials": {
        "anthropicApi": {
          "id": "TPZ3pP8mkx93DY1Z",
          "name": "Anthropic account"
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "GmailTrigger": {
      "main": [
        [
          {
            "node": "Check for pdf",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check for pdf": {
      "main": [
        [
          {
            "node": "Information Extractor",
            "type": "main",
            "index": 0
          },
          {
            "node": "Gmail",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Gmail": {
      "main": [
        []
      ]
    },
    "Anthropic Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Information Extractor",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Information Extractor": {
      "main": [
        [
          {
            "node": "Gmail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "179a82cf-af65-42c0-b8a0-3ea0865959ed",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "7126a4a85868ea99d07cb37d30ec04878c3e9ccfdbfa44cfe54d9c6bc0bf6465"
  },
  "id": "o9ywZUwHkiLG5ysN",
  "tags": []
}```

I solved this for Gmail using a Merge Node

Frustratingly this does not work for Airtable. Please see my next post.

Thanks

1 Like

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