Scenario: You want to process an attachment (let’s say a pdf) in an e-mail that has multiple attachments.
As I couldn’t find an easy way to filter on attachments, I created a Function Node with the following code:
items.json.attachmentIndex = Object.values(items.binary).findIndex(key => key.mimeType === "application/pdf"); return items;
This returns the index of the pdf attachment, which can be used in the Binary property of further Nodes like this:
The above code is based on the assumption that there is only one pdf attachment. But I think it could be easily extended with other criteria, like filename.
Sharing this as it took me a while to figure out how to get to the right attachment (i.e. the one I needed to act upon).
Interested to read if there are other (better!) solutions.