ID gmail items with attachment?

Describe the problem/error/question

What is the error message (if any)? if node always evaluates to false regardless of the presence or absence of an attachment.

Please share your workflow

Share the output returned by the last node:

Information on your n8n setup

  • n8n version: cloud ver 1.11 (I think – latest stable as of Sat morning)
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

I’ve been wrestling with this for a couple of days. I’m trying to ID if gmail items have an attachment based on an example from a book that I’ve moved on from hours ago. Many variants of the expression below, some boolean, some numeric, always resulting in ‘false’ even if there’s an attachment.

{{ Object.keys($binary || {}).some(k => k.startsWith(‘attachment_’) && $binary[k]?.data?.length > 0) ? 1 : 0 }}

Is there a more efficient method of identifying mail items with attachments? The book mentioned there’s a setting options in the email trigger for ‘only attachments is true’ but., that seems to be old information as I wasn’t able to find it.

thanks for any help anyone can provide.

Doug O’Leary

{{ $binary.keys().length }}

should do the trick to identify

  • if there is one attachment:= 1.
  • if there is at least 1: > 0
1 Like

thank you, sir. This looks much more straight forward. KISS principle remains king. I’ll give this a try shortly. I have found an alternat work around which is functional; but, I’m definitely interested in getting the if node working correctly.

1 Like

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