Skip to content

Gmail Inbox Auto-Organizer

$0.00

Automatically organize the emails in your Gmail inbox with this FREE Google Script!

Category: Tags: , , ,

Description

Let me introduce you to my Gmail Inbox Auto-Organizer! I don’t know about you, but I receive tons of emails each day (probably 95% are promotional). Some are my fault; I had signed up for a newsletter on a whim because it was something I was actually interested in (like sales at Michael’s or DSW), and others might just be a result of third party companies selling my data for profit and my email address ended up on some list that’s kind of related to a thing I bought once on eBay three years ago.

My free Google Apps script, Gmail Inbox Auto-Organizer, is exactly what its name describes. It can automatically organize your gmail inbox! Filters only work on incoming emails, but Gmail Inbox Auto-Organizer works on any email that’s just sitting around in your inbox after it’s outlived its usefulness.

Use Gmail Inbox Auto-Organizer to automatically categorize, archive, and/or delete emails after they’ve been sitting in your inbox for a while! If you’re having the same problem that I did, get started today by getting your own copy of my script FOR FREE!

This Google Apps script was first released in July 2017. Read its original announcement. Please note (and this seems obvious to me) that this script only works for Gmail, i.e. the email account you manage with Google. This will not work for Yahoo, Outlook, or any other email account.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Installation Instructions

  1. Log into your Google account that has the inbox you want to organize.
  2. While viewing the script file, navigate to File > Make a Copy. This will make a copy in your Google Drive.
  3. On line 19 where it says var search_term = “category_promotions”;, replace “category_promotions” (while leaving the double quotes in place) to whatever you would use to search your email. Any search operator is valid.
  4. On lines 22 through 31, set the various actions of what you want to do with the emails that meet your parameters to true or false (no quotation marks). Descriptions of what these actions do are explained in the FAQ. By default, only action_delete is set to true.
  5. On line 34, you can change the value of days to how old you want the email to be when it gets automatically sorted. The default is 30, which means it will only sort emails that are 30 days old or older. In case you were wondering, this script is using the older_than search operator in conjunction with your search parameters in step 2 to filter your emails.
  6. On line 37, you can change the value of repeat to how often you want this script to run. The default is 1 so it runs once a day.
  7. Once you’re satisfied with your settings, Click on Run > Run Function > Authorize to allow the script to access your account’s email and manage it.
  8. Click on Run > Run Function > Install to start it on the schedule you’ve set in step 6.
  9. Optional: Click on Run > Run Function > SortGmail to run the script immediately if you don’t want to wait for it’s next scheduled time

And that’s all! If you want to turn it off, just open the script up in your Google Drive and click on Run > Run Function > Uninstall.

Frequently Asked Questions

What does "action_delete" do?

action_delete will send your emails to the Trash folder if it is set to true. They aren’t deleted forever immediately, so you can recover them if it was deleted by mistake. Emails here still count toward your Google account’s storage quota until it is deleted forever.

If you also have action_inbox, action_archive or action_spam set to true, those actions will take precedence, so you should only set one of these four to true while leaving the other three set to false.

Example:

action_delete = true;

What does "action_archive" do?

action_archive will move your email to the “All Mail” area of your account. You’ll also see it removes the “Inbox” label. Emails here still count toward your Google account’s storage quota.

If you also have action_inbox set to true, that action will take precedence. If you also have action_spam or action_delete set to true, this action will take precedence over them. So you should only set one of these four to true while leaving the other three set to false.

Example:

action_archive = true;

What does "action_addLabel" do?

action_addLabel will apply the label you want to the email. This can be a custom or a nested label too. It’s best to avoid using hyphens/dashes (-) in your label’s names as they are seen as label separators in Gmail.

Example adding a custom label called “Projects”:

action_addLabel = "Projects";

Example adding a custom label called “New Website” which is a label nested under “Projects” (note the slash symbol separating the two labels):

action_addLabel = "Projects/New Website";

This does not add the “Inbox” label to your emails. While it appears the same visually, it is not programmatically handled the same way. To add the “Inbox” label, see “action_inbox”.

You can manage your labels by clicking on the gear icon in your Gmail (web browser version), and navigating to Settings > Labels.

What does "action_removeLabel" do?

action_removeLabel will remove the label you want from the email. It’s best to avoid using hyphens/dashes (-) in your label’s names as they are seen as label separators in Gmail.

Example remove a custom label called “Projects”:

action_removeLabel = "Projects";

Example removing a custom label called “New Website” which is a label nested under “Projects” (note the slash symbol separating the two labels):

action_removeLabel = "Projects/New Website";

This does not remove the “Inbox” label from your emails. While it appears the same visually, it is not programmatically handled the same way. To remove the “Inbox” label, see “action_archive”.

You can manage your labels by clicking on the gear icon in your Gmail (web browser version), and navigating to Settings > Labels.

What does "action_inbox" do?

action_inbox moves the email to your Inbox tab. You’ll also see it adds the “Inbox” label.

If you also have action_archive, action_delete, or action_spam set to true, those actions won’t do anything since this action will take precedence over all of them. So you should only set one of these four to true while leaving the other three set to false.

Example:

action_inbox = true;

What does "action_important" do?

action_important marks the email as important.

Example:

action_important = true;

Learn more about Importance markers in Gmail.

What does "action_unimportant" do?

action_unimportant removes the important mark from the email.

Example:

action_unimportant = true;

Learn more about Importance markers in Gmail.

What does "action_read" do?

action_read marks the email as read.

Example:

action_read = true;

What does "action_unread" do?

action_unread marks the email as unread.

Example:

action_unread = true;

What does "action_spam" do?

If you also have action_inbox or action_archive set to true, those actions will take precedence. If you also have action_delete set to true, this action will take precedence over that. So you should only set one of these four to true while leaving the other three set to false.

Example:

action_spam = true;

What will happen if I add and remove the same label?

If you set the same label for both action_addLabel and action_removeLabel, ultimately nothing will happen.

In the code, it first checks if there is a label to add, then it adds it. It then checks if there is a label to remove, and then it removes it.

What will happen if I set both action_read and action_unread to true?

The code is written where it first checks if action_read is true, regardless if action_unread is true, so the ultimate result is that the email will be marked as read.

What will happen if I set both action_important and action_unimportant to true?

The code is written where it first checks if action_important is true, regardless if action_unimportant is true, so the ultimate result is that the email will be marked as important.

What will happen if action_inbox, action_archive, action_spam, and action_delete are all set to true? Or more than one of those is set to true?

The code is written where it first checks if action_inbox is true, regardless of what the other three are set to, so the ultimate result is that the email will be moved to your inbox if action_inbox is true.

If action_inbox is false, then the code looks at the value of action_archive. If that value is true, then the email will be moved to your inbox regardless of the values of action_spam or action_delete.

If both action_inbox and action_archive are false, then the code looks at the value of action_spam. If that value is true, then the email will be moved to your spam box regardless of the value of action_delete.

action_delete will only move your email to the Trash (not permanent deletion) if its value is set to true AND the other three actions are false.

Can I have an example of moving all unread emails that contain "Foo" in the subject to my custom "Bar" label, while removing the "Inbox" label and marking it as read?

Sure can!

var search_term = "subject:Foo label:unread";

//What action to perform upon sorting.
var action_delete = false;
var action_archive = true;
var action_addLabel = "Bar";
var action_removeLabel = false;
var action_inbox = false;
var action_important = false;
var action_unimportant = false;
var action_read = true;
var action_unread = false;
var action_spam = false;

Can I add or remove multiple labels?

Not at this time, but if you contact me and ask for this feature, I can add it. I just haven’t had a need for it and nobody has asked yet!

Can I run multiple searches?

Yes and no.

You cannot run multiple searches with a single script. However, you can totally make as many copies of the script as you want all with different settings and all running simultaneously.

Though I’d recommend renaming them in your Google Drive to be descriptive as to what they’re organizing.

Alternatively, I’ve been using gmail filters to apply a “Temp Notif” tag to existing and incoming emails and then I use a single script to work on that tag.

Donate

This is a FREE product that I poured a little bit of my heart and soul into with the sole purpose of being helpful to you. Please help support my small business by donating! Donations assist in maintaining this product, my other free products, and my pro-bono projects by keeping me inspired and allowing me to set aside the time to work on these! Time is money after all!