GithubHelp home page GithubHelp logo

asparagustuss / gmail_auto_delete Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 0.0 86 KB

Google Apps Script that auto deletes emails nightly based on options: Age, Size, Has Attachments, File Types, Starred, Important, User Labels, Cats, From, Unread, Snoozed, etc..

License: GNU Affero General Public License v3.0

JavaScript 100.00%
gmail delete autodelete automation google apps script

gmail_auto_delete's Introduction

Gmail_Auto_Delete

Google Apps Script that auto deletes emails nightly based on options: Age, Size, Has Attachments, File Types, Starred, Important, User Labels, Cats, From, Unread, Snoozed, etc..

About:

With drive capacity now being a thing for Google services this seems really useful to me. The script works by deleting in blocks of 200 up 1000 per tiggered instance. After 1000 emails have been deleted if there are more remaining it will start another trigger in 60 seconds. If no emails are left to delete then the nightly trigger is created. It looks like about 3000-4000 emails is the most that can be deleted in a day. Based on how many excess emails you have this could take a week or more.

When reviewing the code the trigger creation and deletion method may seem odd, but Google seems to be limiting how triggers can be run and how many can be run consecutively. If too many triggers are run one after another then it will just cancel all triggers for the project--even a nightly. The method employed here ensures that reguardless of what shenanigans Google is using on the server side to stop triggers this code will always rerun nightly.

How to Deploy:

  • Copy and paste the code into the an new .gs file on https://script.google.com/.
  • Set your options with the scripts constants (explained below)
  • Start the 'startup' function.
  • Done!

*if you want to test the deletion results before deploying setup your options and run the 'generate_search' function. Copy the log search output and paste into Gmail. The Gmail results shown are the exact results that will be used by the script for deletion.

Options Explained:

  • DELETE_AFTER_DAYS: Only delete emails older than X days (0 includes EVERYTHING/All emails reguardless of when received)
  • MESSAGE_MB_MINIMUM: Only delete emails that are at least X MB (0 includes EVERYTHING/All emails reguardless of size)
  • HAS_ATTACHMENT: If true, only email with an attachement will be deleted.
  • CONTAINS_FILE_TYPES: Only emails containg the listed file types will be deleted.
  • SKIP_STARRED: If true, any email that is been starred will NOT be deleted.
  • SKIP_SNOOZED: If true, any email that is snoozed will NOT be deleted.
  • SKIP_UNREAD: If true, any email that is unread will NOT be deleted.
  • SKIP_SENT = true: If true, all items in sent folder are NOT deleted.
  • SKIP_IMPORTANT: If true, any email assigned Important is NOT deleted. *Important emails are auto flagged by a gmail algorithm. Chances are these emails are not in fact important to you (defualt is False).
  • SKIP_USER_MADE_LABELS: If true, any email with a user made custom label is NOT deleted. You dont need to identify them. The script looks up all labels and skips any label that was created by the user.
  • SKIP_FROM_LIST: Emails received from these specific addresses will never be deleted reguardless of any settings above
  • SKIP_CATEGORY_LIST: Emails received from these specific categories will never be deleted reguardless of any settings above

gmail_auto_delete's People

Contributors

asparagustuss avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

gmail_auto_delete's Issues

not working

Отладка error!:ReferenceError: b is not defined

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.