Hi everyone,
I’m trying to Automate upload my Gmail Attachments to GDrive. I set up a router to create a folder (which is named by email adress) if it doesn’t exist and upload it in that specific folder.
If it exist, i would like to upload it in that folder.
My issue is in that second path.
The first time i only had the “Upload File” set to the folder ID (via Search File/Folder), but it kept giving the error " * RuntimeError [404] File not found: vnd.google-apps.folder."
I then tried the Make AI to correct that, which suggested to put an error handler to resume the scenario.
At first i thought it worked, but then on gmail i only see 1 file uploaded while there would be 5.
I tried with an iterator but same issue.
Does anybody have an idea ?
Thanks
Welcome to the Make community!
You’ll need to use the Iterate Attachments module after the watch emails module.
Hope this helps! Let me know if there are any further questions or issues.
— @samliew
P.S.: Did you know, the concepts of about 70% of questions asked on this forum are already covered in the Make Academy. Investing some effort into it will save you lots of time and frustration using Make later!
Hello! Welcome to the Make Community!
In your scenario, there are some things you need to change:
-
just after the Watch email, you should add a Router. In Route 1, you should search the folder in Gdrive. Then, a second router => route 1a (folder found => SET VARIABLE 'FOLDER_ID"=the ID of the found folder), route 1b (fallback => Create Folder, and SET VARIABLE 'FOLDER_ID" = the ID of the folder you just created).
-
when this 1st route is done, you have a variable called FOLDER_ID that contains the ID of the folder (found or created).
-
you add a second route, there, you do a GET VARIABLE (FOLDER_ID); it will retrieve the variable you have set in Route 1
-
then you add you iterator, and Google Drive / Upload a file. You will map the FOLDER_ID variable and the data from the Iterator.
-
if you want to leave the error handler, you don’t need “Resume” but “Ignore”. But normally, you should not have any error.
Can you try and give it a try? Let me know if you are stuck anywhere
Benjamin
Hey @samliew, how are you?
@Tristan_Muller wants to create the Folder once, with the email of the sender; that’s why it’s better the Iterator is later in the scenario.
Benjamin
Hello, Thanks @Benjamin_from_Make for your advice.
I updated the scenario, but i get the same result as before. I’m new to the make.com playground, I’m not quite sure I got everything you told in your reply (especially the set/get variables and the iterator, where i’m not sure which id i should put)
The folders are created kind of accordingly (I’ll come back to that when that when the first scenario is complete to optimize the full stuff), it seems the files are sent to the second route, the iterator get the files, but nothing goes to the upload files module.
1 Like
Rebonjour Tristan!!
You’re almost done!
You need to change the SET and GET Variable. their goal is to save a variable giving it a name, so that you can retrieve it in another route.
So for ALL SET Variable and GET Variable, change the “Variable Name” to “folder_id”.
For the one with ID 12 (the top one), map the ID of the folder retrieved in step 3
It should look something like this
The SET VARIABLE with ID 14 should have the same “variable name” (folder_id), but this time its value should map the file id of step 13
The GET VARIABLE with ID 19 should have “folder_id” in the field Variable name. Like this
What are we doing?
In the first route, we store a variable called “folder_id” that contains the ID of the folder where you want to store the files. This ID can be the one you found, or the one you just created.
Then, in the second route, you retrieve this variable. This is the only way to “share” a variable between routes.
And then the iterator is here to iterate through all the attachements (if there are more than one). You could have also used GMAIL/Iterate Attachments instead.
In the array, field of the Iterator, you have to map the Attachments field from your GMAIL/Watch emails. It will look like this:
And then, in Google Drive “Upload a file”, you have to map the “folder_id” variable (from step 19 if you didn’t remove/added the GET VARIABLE), and leave “Iterator” in the File field.
It should look like this:
If you are lost anywhere, let me know.
A bientôt
Benjamin
1 Like
Hi @Benjamin_from_Make ,
Your answer is incredible, it works like expected.
I’d like to fine tune this scenario so i have some questions :
- I tried to filter the attachments (only pdf, no png) but it didn’t seem to work, what did i do wrong ?
- The Watch Gmail module seems to often lose the “When to Start” information when i run once. Would it happen too if i schedule every month ?
- I’m thinking about sorting the mail first by date (a big folder for the year) then by email adress
- For the email adress, i was wondering if i use the same label for different email adress, would it be possible to regroup those different adress attachment in one folder (the labeled one ?)
If i’m pushing too much on my questions, don’t hesitate to say it
Thanks a lot !
1 Like
Hello!! I’m happy it worked for you!
Let me try and answer your different points:
-
I tried to filter the attachments (only pdf, no png) but it didn’t seem to work, what did i do wrong ?
Ben => In fact, since there can be multiple attachments, some PDF, some PNG or other formats, you need to verify the type just after the Iterator (your scenario will create a folder even if there is no PDF attached, but maybe your are ok with it?). So, after the Iterator, you can add a filter that lets pass only files with mime type = application/pdf. Like this
If you want to stop any processing if there is no PDF at all (no attachment, or multiple attachments but no PDF, you can still do it with functions, in a filter sitting just after the Watch emails. It would use map and contains functions, like this:
If I summarize, we say "extract the field contentType from Attachments (it becomes an array with the Mime type of all attachments), and continue if you find “application/pdf” (contains returns TRUE)
In that case you still need the other filter, because if, for ex, there are 3 attachments, you want to upload only the PDFs.
-
The Watch Gmail module seems to often lose the “When to Start” information when i run once. Would it happen too if i schedule every month ?
Ben => In fact, the Watch modules like that can keep track of the last record they grabbed last time the scenario executed. It allows you to get only the new emails everytime it executes. But when you are developing your scenario, you want to test over and over. In that case, you need to play with “Choose where to start”. Once the scenario is ready, you do a last Choose Where to Start to pick when you want it to extract emails. After that, it will handle everything alone.
BUT, be careful, by default, watch Emails is configured to grab only 1 email at a time. it means that if you schedule your email to start every month, it will get only one email… (so only 12 emails per year…). You have to change this default value to a higer number, or schedule your scenario to run more often. The tuning of scheduling+number of results depends on the volume of emails you receive.
-
I’m thinking about sorting the mail first by date (a big folder for the year) then by email adress
Ben => You can do that. The logic will be a little more tricky. You will have to play with the root folder where you search and create your subfolder. For example for Search Folders, you would use ‘map’ in the “Choose a Folder” and use Date functions to set the years/month/day as you want. It’s not simple because I’m not sure Google Drive allows you to create in one step folders and subfolders…
-
For the email adress, i was wondering if i use the same label for different email adress, would it be possible to regroup those different adress attachment in one folder (the labeled one ?)
Ben => It depends on how you want to Label; but you could do it. For instance, you could use a Switch module or a Switch function on part of the emails to generate the label according to a criteria (ex: MAKE for all emails in the make.com domain, or GMAIL for all emails in the gmail.com domain, etc). It really depends on what you want to do. Then, you could use this label to generate the folder name, instead of the email address.
I hope I was clear