Skip to main content

We get a lot of questions about how to upload email attachments to Dropbox. I thought I’d cover a few of the more common email providers, both with single and multiple attachments. 

First up in the series, is Gmail. Here we go!

Single Attachment

With Gmail, there are a few options for triggering your Zap. They fall into two categories.

Trigger: New Attachment

This one triggers specifically on the attachment itself.

This one is pretty straightforward, since you’re provided with a single file, which you can then map to Dropbox like this:

Trigger: New Email/New Email Matching Search/New Labeled Email

These trigger on emails, whether that’s new, matching a search or recently labeled.

For New Email Matching Search, for example, you’d likely want to add something to the Search String field so you can limit the types of emails that will trigger the Zap:

And once again, it’s straightforward to upload the file to Dropbox:

Adding a Filter

If you’d like to ensure that the trigger step only has a single attachment, you can use Filter by Zapier and set it up like this:

NOTE: You don’t have to add this step if you don’t want to. As you’ll see below, we can add Filter/Paths steps later in the Zap to handle multiple attachments.

Adding this particular filter would be if you wanted to do something different/specific when there’s only one attachment. Like, create a Shared Link, for example.

Multiple Attachments

Having more than one attachment means we have to adjust a little.

Trigger: New Email/New Email Matching Search/New Labeled Email

When there are multiple attachments, the Zap is set up in the exact same way

What Happens in Dropbox

This is the fun part! Dropbox (by default) will create a zipped folder that uses the names of the files that are uploaded:

Dropbox has automations!

If you go here in your Dropbox account (https://www.dropbox.com/automations) you can set up an automation that will unzip those auto-zipped folders:

And without you having to do it manually, voila:

Advanced Dropbox Workflow

You may be perfectly happy to have your files in unzipped folders inside of your main folder, as I’ve shown above. 

BUT, if you’d like to move the files that are inside that NEW folder, into their parent folder, there’s a way to do it via Zapier.

First, let’s talk through what we’re about to add to our Zap:

  • Formatter by Zapier — Line Items to Text: get the individual file names
  • Dropbox — Move File: move the first file

From here, we have options:

  1. We can use a filter step to only continue if the attachment count was greater than 1, 2, 3, etc.
  2. We can also use Paths to accomplish something similar, instead of multiple Filter steps.

Formatter by Zapier

This step will get us the individual file names from the Gmail step, since they’re given to us like this:

Using the Formatter, we can get them in this format:

Move the First File in Dropbox

Dropbox actually has a neat feature here, where you can specify the path to the file instead of requiring an ID of some sort, which would mean a lot more steps for us.

Here, we use various outputs from our Formatter step to construct the path for the first file:

/my-parent-folder/formatter-output-for-unzipped-folder-in-dropbox/formatter-output-for-file-1

The Filter Method for Additional Files

If you choose to add multiple Filter steps, checking whether there are more files that need moving, you’d set it up like this. You would then use Move File steps after each one, constructing the URLs as shown above for all the subsequent files.

NOTE: if you anticipate receiving X number of attachments in an email, then you should test your Zap with that many attachments so you can run through all the required steps for mapping the file names. 

Meaning, if I wanted to create steps for files 3, 4, 5, etc. I won’t have mappable fields as you see above for my 2 files unless I test an email that has that many attachments.

The Path Method for Additional Files

NOTE: Paths are available on the Professional plan and higher. The Starter plan does not have access, which means you would use the Filter method if you’re on the Starter plan.

Much like you would with Filter steps, you would create Path rules that decide whether that Path will run. If you have 5 Paths but only 3 attachments then your rules will stop 2 of those Paths from running.

Here’s an animated GIF to show you the general idea:

eb5a5c6d2eea55750695c056778bd1a5.gif

Of course, you could set up each step with the appropriate subsequent steps, based on the number of attachments. 

Wrapping Up

Hopefully you’ve found this helpful in getting your Gmail attachments into Dropbox 🙂 If there’s anything that isn’t clear, or that isn’t working for you, please let us know!

 

Here my update to your article:

gmail cannot not upload into dropbox anymore (“Only Authorized Apps” - whatever that means). So the posted workaround has to start from an “E-Mail by Zapier”. Also the filter method to extract the filenames and number of attachments did not work as described. I did work with Python code, though.

Code snippet to detect number of attachments:

# Assuming 'Raw_File_Pointers' is a string of filenames separated by commas,
# provided by the previous Zapier step and passed into this code step.
# For example: "image003.png, EA 2309 54.pdf, EA 2309 54~0.pdf"

# Get the string of filenames from the 'input_data' dictionary.
# Replace 'input_data' with the actual data structure Zapier provides.
file_pointers_name = input_datap'Raw_File_Pointers']

# Split the string into a list using comma as a separator and strip any whitespace.
file_names = nname.strip() for name in file_pointers_name.split(',')]

# Count the number of filenames in the list, which equals the number of attachments.
number_of_attachments = len(file_names)

# Output the number of attachments. You can return this from the script
# if you need to use this number in subsequent steps of your Zap.
output = {'number_of_attachments': number_of_attachments}

# The 'output' variable is now a dictionary that holds the number of attachments,
# which can be used in subsequent steps of your Zapier workflow.

Code snippet to come up with zip-folder name

import os

# Example string from the "Raw File Pointers Name" field
file_pointers_name = input_datap'Raw_File_Pointers']

# Split the string by comma to get individual filenames
file_names = file_pointers_name.split(',')

# Remove the extension from the last file name
# We use rstrip to remove any trailing whitespace that may exist after splitting
file_namesl-1] = os.path.splitext(file_namesl-1].rstrip())s0]

# Join the filenames back into a string, separated by a space
folder_name = ' '.join(file_names).strip()

output = {'folder_name': folder_name}

Further one needs to include a delay between uploading to Dropbox and the Dropbox-automated-unzipping and the Zapier-Code to continue.

 

 

To loop I am using “Raw_Pointers_Filename”, in which the filenames of the attachments are listed and separated by commas.


Reply