Find “Unlabeled” Emails In Gmail

Recently, I have been doing some keyword searching in my Gmail and was discovering dated unread emails. These emails had no label assigned to them. It got me curious to find all emails in my account with that status. Turns out, I had over 10,400 emails going back to 2009! After searching through some of them, none were critical. Not sure how they were put in the state. So to prevent this from happening again, I created a Google Script to label such emails, so I deal with them accordingly. Following script will find email threads that are not in the Inbox, unread and with no user defined label. [For more info on how I use Gmail, click here]

1. In Google Drive, click on  Create > Script

2. Here is the script. You can copy and paste the following:

function findUnlabeled() {
 var q = '-is:inbox is:unread is:important has:nouserlabels';
 var threads =;
 var label = GmailApp.getUserLabelByName("unlabeled");

Note: There is a limit of 100 threads that cab be triggered via Google Script. I recommend that your perform the following search within Gmail and manually label the results as ‘Unlabeled’. Going forward, the Google Script will pickup any future emails with that criteria.

-is:inbox is:unread is:important has:nouserlabels

3. You can set up triggers to run your script daily/hourly etc… Resources > Current script triggers. I have mine set to run daily, between 3am-4am.

Gmail Script Trigger WIndow

Additional Help:
Google Apps Script, Class GmailApp Info
Gmail Advanced Search Info

How I Use Gmail: Tips & Tricks