In Gmail, labels attach to individual messages, not whole threads. This means that new arriving messages in a thread will not always be given existing labels unless they are manually reapplied.
To work around this issue, this project uses a Google Apps Script to periodically add missing labels to all messages affected.
- Enable the Google Apps Script API at https://script.google.com/home/usersettings
- Create a new project at https://script.google.com/home
- Clone or download this repository
git clone [email protected]:ariasemis/propagate-gmail-label.git
- Edit
.clasp.json
file with thescriptId
of the project you created - Push changes to google apps script project
npm install npx clasp login # access your Google account npm run push
- Open project on script.google.com and run
install
function
To stop the script from running you can execute the
uninstall
function provided in the script.
The following options can be configured in Project Settings>Script Properties:
Property | Default Value | Description |
---|---|---|
DAYS_BETWEEN_RUNS | 1 |
Frequency in days at which the script will run |
TIME_OF_DAY_TO_RUN | 5 |
Specifies the hour at which the script runs |
DRY_RUN | false |
When true , the script will only log results without applying changes to message labels |
MAX_THREADS_PER_RUN | 20 |
Maximum number of message threads to process per run |
NO_LABEL | uncategorized |
Name of the label to add to threads without any label |
Inspired by Tom Scott's post on fixing Gmail labels.