Move a filtered thread that skips INBOX to INBOX in Gmail if you reply to a message there or Star it

Published: by

  • Categories:

If there is a a mailing list which is filtered and doesn't pass my INBOX, even if I reply to a thread in it, it'll still goto the filter and skip in INBOX. Well, this is perfectly defined behaviour but due to this, I sometimes miss mails. Another scenarios is when you want Starred conversations to never skip INBOX.

The script below solves this problem.

function move_to_inbox(threads) {
   Logger.log(threads.length);
   for each (thread in threads) {
	   if (thread.isInInbox() != 'true') { 
		   thread.moveToInbox();
		   Utilities.sleep(1000);
	   }
   }
}

function main() {
	move_to_inbox(GmailApp.search('in:sent OR is:starred -label:Inbox', 0, 50));
	//MailApp.sendEmail("[email protected]", "Script Log", Logger.getLog());
}

Goto http://script.google.com and copy the above script there. Then, setup triggers (Resources->All Your Triggers) to execute main() every minute.

OR

save the script in your google account by visiting this link.

Make sure that triggers are set to work correctly.