Issue with Filtering PDF Attachments in Automation

Hi everyone,

I’m working on my first automation that monitors incoming emails, checks their attachments, and continues processing only if at least one of the attachments is a PDF file. If no PDF is found, the automation follows a fallback route.

I have uploaded all the images of problem here: Imgur: The magic of the Internet

Here’s what I need to achieve:

  1. The automation should check if any email attachment contains a .pdf or .PDF file.
  2. If no PDF is found, the router should direct the process to the fallback route. If a PDF is found, the automation continues by iterating through the attachments.
  3. It should filter out only the .pdf or .PDF files and upload them to OneDrive before proceeding further.

The issue:
For some reason, when a PDF file is not the first attachment (e.g., the first file is a .jpg, .doc, etc.), my filter doesn’t work as expected (see attached images).

I’ve tried troubleshooting, but I can’t spot the issue. Even the Make AI agent couldn’t help.

I’d really appreciate any advice! Thanks in advance for your time.

I may have found out that in the filter - only first attachment is considered. Is there a way that all the attachments are considered and if any of it contains .pdf it goes through?

You can use the Iterate attachments module to iterate through all attachments of each email and then place your filtering logic after.

Hi Harvey,

thanks for answer! I think your recommended solution would not work correctly. If i had 2 attachments - one .pdf and one .doc - the .doc one would trigger bundle 2, which would result in error.

I found a workaround by using text aggregator tool. I first aggregate MIME type of all attachments into text and then check if any of the attachment contains “pdf”. If not, fallback route is used. If there is a file, then the automation proceeds.

Then I iterate files again and use your suggested solution.

Thanks!

Martin.

4 Likes

Welcome to the Make community!

You don’t need any iterator or aggregator for this, saving two operations.

To do this, you can use the built-in function map

{{ map(complex array; key) }}

For more information, the function’s documentation can be found in the Help Centre. You should also complete the tutorials in the Make Academy.

Example

Here is an example of how your scenario could look:
Screenshot_2025-03-14_210358

This is just an example. Your final solution may or may not look like this depending on your requirements.

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.

2 Likes

Hi samliew,

thanks a lot for answer and recommendation. I have tried this solution before and after you mentioned it and I think i might have a mistake somewhere in the arrays or idk. Please could you take a look once more at it and tell me what might be the problem?

My output of email is following:

emailoutput.txt (43.7 KB)

And my filter looks like this:

But for some reason, it does not work and the filter fails. I think it checks only the first position of the array.

Thanks! martin

You have two mistakes.

  1. Extra stray ) at the end

  2. Array operators: Contains, MUST be the exact full string.

For more information, see and compare the difference between my screenshot and yours.

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.

1 Like