Advanced Gmail Filters That Aren't Available in Gmail

Gmail filters help you automatically sort email messages based on rules. So if your boss has sent an email message, the filter can mark it as important. If the email has the word “Unsubscribe” somewhere in the message body, it can be marked as a promotional message and so on.

How to Create Advanced Gmail Filters

While the built-in Gmail filters are powerful, they do have certain limitations.

For instance, you cannot have a Gmail filter that does case-sensitive search. It will treat WHO and who as same. Gmail filters won’t do pattern matching (regular expressions) so you cannot have a filter for messages that contain phone numbers.

We often get spam messages that have a few dozen addresses in the TO and CC fields but there’s no filter to automatically redirect such messages to the SPAM folder of Gmail. That’s where Google Scripts can help. You can setup advanced filters that aren’t available in the native version of Gmail.

Advanced Gmail Filters

What you see above is a set of 10 Gmail filters that were created with Apps Script. You can have a filter to process messages that contain tons of links. Or messages that have too many attachments. Or messages that have just a word or two in the message body.

The best part is that you don’t have to know scripting to use either of these filters. Just follow these 3 easy steps:

  1. Click here to copy the Gmail Filters sheet into your Google Drive. You can write OFF to deactivate any of the available rules.
  2. Go to the Gmail Filters menu in the sheet, choose Initialize and grant the necessary permissions to the script.
  3. Now choose Turn-on Gmail Filter to activate your filters. You may close the Google sheet now.

Here’s what happens behind the scenes. The script will run in the background every 10 minutes and monitor any new unread messages in your Gmail inbox. It will then run the various rules against these messages. The native filters in Gmail take precedence and then your custom rules specified in the sheet are applied.

You can also look at the source code to understand how the various rules were created.

[ctrlq]

Amit Agarwal is a web geek, solo entrepreneur and loves making things on the Internet. Google recently awarded him the Google Developer Expert and Google Cloud Champion title for his work on Google Workspace and Google Apps Script.

Awards & Recognition

Google Developer Expert

Google Developer Expert

Google awarded us the Developer Expert title recogizing our work in Workspace

ProductHunt Golden Kitty

ProductHunt Golden Kitty

Our Gmail tool won the Lifehack of the Year award at ProductHunt Golden Kitty Awards

Microsoft MVP Alumni

Microsoft MVP Alumni

Microsoft awarded us the Most Valuable Professional title for 5 years in a row

Google Cloud Champion

Google Cloud Champion

Google awarded us the Champion Innovator award for technical expertise

Want to stay up to date?
Sign up for our email newsletter.

We will never send any spam emails. Promise 🫶🏻