Skip to content

Instantly share code, notes, and snippets.

@simon57nz
simon57nz / README.md
Last active September 11, 2018 01:47 — forked from soxofaan/README.md
Script for autodeletion of Gmail threads based on a label structure.

Google Apps Script to automatically delete mails with a certain label after a certain time

Forked from : https://gist.github.com/soxofaan/92fab6776c1bfcac060544ba0c9dd59c

Usage

  1. Think of a deletion scheme and create GMail labels accordingly I use a three part label, parent label is "autodelete", next level is number of days, third level is descriptive. (e.g. I have labels like "autodelete/7/facebook" and "autodelete/15/linkedin")
  2. set up filters in GMail to flag desired mails with these labels
  3. create a Google Apps Script with this script (adapt function names, labels and day offsets appropriatedly) and set up triggers as desired
  4. I also star messages to prevent autodeletion.