Automatically deletes old emails that match the specified label.
- Create a new Google Apps Script at https://script.google.com
- Overwrite the placeholder with the javascript below
- Update the following constants:
LABEL_TO_DELETE
: the label that should be have old messages deletedDELETE_AFTER_DAYS
: the age of messsages after which they will be moved to trash
- Save the script, then run:
Initialize
Install
If you ever want to remove the script, run Uninstall
to remove any left over triggers.
- Added support for multiple labels
- Added configurable
TRIGGER_NAME
- Increased default page size
- Decreased default delay between receipt and delete
- Removed use of deprecated
Session.getTimeZone()
- Improved efficiency for long threads by checking
thread.getLastMessageDate()
H/T: Arun's post How to Auto Delete Old Emails In Any Gmail Label
Hi,
I really think the concept is terrific. Thank you. However, I am unable to make this script work. I would be grateful for some help.
The emails I would like to delete are labelled ‘Home-Security’ and is not nested underneath another label.
I adjusted the script to reflect :
The first 12 lines of script are:
// The name of the Gmail Label that is to be checked for purging?
var LABELS_TO_DELETE = [
"Home-Security"
];
var TRIGGER_NAME = "dailyDeleteGmail";
// Purge messages in the above label automatically after how many days?
var DELETE_AFTER_DAYS = "0.25";
I have also installed and initialised the script.
I attach screenshots of the reports ‘My Executions’