A script to delete all trash emails based on keyword and label filters.
- Install Node.js & npm
- Create a Google Cloud Platform project with the API enabled.
- Create Authorization credentials for a desktop application and download
credentials.json
file in the project directory. - Run
npm install
in the project directory. - Rename
keywords.json.sample
file tokeywords.json
and update its contents. - Run
node .
In addition to the steps above, to run this script in Google Cloud automatically at regular intervals, you can do the following:
-
Create a HTTP triggered Cloud Function.
-
Copy
index.js
,package.json
,keywords.json
,tokens.json
, andcredentials.json
to the Cloud Function. -
Create a Cloud Scheduler Job with Authentication.
-
Add Cloud Functions Invoker role to the Service Account created for Cloud Function.