Logo of Delete your emails by Planta, composed of geometric blocks in red, yellow, and gray.

CREATE YOUR EMAIL CLEANER

To become a digital pollution hacker,

you need a computer.

Open your computer

to follow these 3 steps.

Let’s create your automatic email cleaner

to reduce your digital footprint

Today, in Hacker for a While, you’ll learn how to create a script. What’s that? Don’t worry, it’s easier than it sounds: you’ll give your computer some instructions to select all emails containing the keywords you choose (for example, “OFFER” or your ex’s name), group them, and make it easy for you to delete them.

Just follow these 3 steps:

1.

Create your script

2.

Paste it into your email

3.

Delete your emails

Let’s keep going!

Paste it into your email

Step 1.

Open Google Apps Script

First, open Google Drive in your browser.

Open Google Drive

Next, click on “New” in the top-left corner.

Illustrative image of the indication

Now select More > Google Apps Script. This will open a new window or tab with the Google Apps Script editor.

Illustrative image of the indication

Great! You’re now in Google Apps Script

Step 2.

Create a new project

When the Google Apps Script editor opens, you’ll see a file named Code.gs.

Delete everything in that file so it’s empty.

Illustrative image of the indication

Step 3.

Paste the script

Copy the script you generated.

Copy code

Paste the script into the empty Code.gs file.

Illustrative image of the indication

Step 4.

Save the project

Click the save icon (the disk or go to “File > Save”).

Illustrative image of the indication

Give your project a name, for example, “Delete Your Emails.”

Illustrative image of the indication

Step 5.

GRANT permissions

Click the Run button (above the code area) and select the DeleteYourEmails function.

Illustrative image of the indication

The first time you run it, Google will ask for permissions to let the script access your Gmail account.

Illustrative image of the indication

Click Review “Permissions” and select your Google account.

Illustrative image of the indication

Authorize the script by clicking “Allow”.

Illustrative image of the indication

Check that the script ran correctly.

Illustrative image of the indication

Awesome! The script has been executed.

Go to your inbox and look for a folder named “delete your emails.”

Step 6 (Optional)

Automate the script

On the left menu, click the clock icon (or select Triggers from the top menu).

Illustrative image of the indication

Click Add Trigger (a blue button in the bottom-right corner).

Illustrative image of the indication

Set up the trigger:

1. In the first dropdown, select the DeleteYourEmails function.

2. In the second dropdown, select “Time”.

3. In the third dropdown, choose how often you want the script to run (e.g., “Daily” if you want it to clean your inbox every day).

Illustrative image of the indication

Click “Save”.

Illustrative image of the indication

Let’s finish this!

DELETE YOUR EMAILS

Step 1.

Select the folder

First, open Gmail in your browser.

Open Gmail

Then, select the label “delete your emails.”

Illustrative image of the indication

Step 2.

Select the emails

Click the top selector to check all emails.

Illustrative image of the indication

You’ll see a message above the emails that says, “Select all [xxx] conversations…” Click on it.

Illustrative image of the indication

Step 3.

Delete the emails

Press the delete button.

Illustrative image of the indication

Step 4.

Empty the trash

We know it’s a hassle, but it’s necessary.

Illustrative image of the indication

You did it!

Emails deleted. Because carrying years of newsletters wasn’t a sustainable hobby.

4. Las etiquetas ya están capturando tus mails. Ahora tan solo te queda borrarlos.

Revisa los mails etiquetados y elimínalos.

[contador etiquetas, columna 1] ¡Ya hemos capturado xxx mails! [contador etiquetas, columna 2] Eso son un ahorro del CO2 equivalente a xx bolsas de plástico.

Y tú, ¿cuántos mails capturaste y eliminaste?

GrCO2e: -

Kilómetros en auto: -