Upload Attachments from Gmail to CRM Affinity

Userlevel 1



I want to create a zap that has multiple attachments, but I need to upload them in Affinity.

I set the triggers as New Email Matching Search in Gmail:

But I am failing in finding all attachments, only shows one.

Additionally, I would like to receive some hints on how to upload in Affinity. I can upload files that have a URL, but the ones that come in the email, they are usually pdf and excel files.


Thank you!

5 replies

Userlevel 1

Hello again,

Here is the link to the Zap:




Can someone give an input why I am not able to upload the files?

If there are more than one file, in any excel format, should I add another step, with file_csv, file_xlxs?

Thank you!!

Userlevel 1

I changed the trigger for New attachment in Gmail, so it will have a trigger for each attachment, which suits better our workflow.

I am still having troubles with uploading the file:



Here is the original copy of the code. Somewhere along the lines, ‘org_id’ should be ‘organization_id’. Cheer! Feel free to reach out to me at



# Download the file / hydrate the file
f_downloaded = requests.get(input_data['file_url'])

# Get the full url of the file
url = input_data['file_url']

# Get the file name
filename = url[url.rfind("/")+1:]
filename_small = filename.replace(".", "_small.")

# Post request to upload the file
response ='', auth=('',input_data['api_key']), params=({'organization_id': input_data['org_id']}), files={'file': (filename_small, f_downloaded.content, f_downloaded.headers['content-type'])})

# Output the response
output = [{'download status': f_downloaded.status_code, 'upload status': response.status_code, 'file name': filename_small}]


Userlevel 1

Thanks Aaron! I did this changes in the organization_id, but for pdf and xlsx files, which are the ones I receive from emails, I can’t make it work yet.


Userlevel 1

Is there a way to transform the files uploaded in Google Drive in URL?