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
This has been awesome up until about 5 months ago when gmail changed some permission stuff. I'm trying to get working again. I want to tell script to delete Inbox after 1000 days. Is there a way to do this? Adding 'Inbox' as such
// The name of the Gmail Label that is to be checked for purging?
var LABELS_TO_DELETE = [
"notifications-github",
"notifications-trello",
"notifications-hipchat",
"Inbox"
];
does not work. Any body know how to achieve this?