Skip to content

Instantly share code, notes, and snippets.

@amityweb
Last active December 17, 2015 14:48
Show Gist options
  • Save amityweb/5626648 to your computer and use it in GitHub Desktop.
Save amityweb/5626648 to your computer and use it in GitHub Desktop.
Receive GMail Email at a Specified Time
/*
The problem with email is it arrives at the time it arrives, and not when you you want it to arrive,
and it's a common habit to press the Send and Receive button all the time. So this script and technique
will prevent any email that has arrived in Gmail from in fact being downloaded to your mail client apart
from the specified times. Good for productivity, email management and less distractions
This script is best used when a third party mail application is used to read mail, and not the Gmail
interface itself.
GMail Requirements:
- A label called "Hold"
- A Filter with search "in:inbox" which moves all messages to label Hold
- The label Hold is hidden in IMAP
- The script should have a Trigger assisgned to it such as a Time-driven Day Timer, e.g. 12pm to 1pm
The above label and filter will move all new messages that arrive in the Inbox into a Label called Hold,
which you cannot see in your Mail application. This script then moves them into the Inbox at the Trigger
time created.
Docs Reference: https://developers.google.com/apps-script/overview
*/
function moveToInbox()
{
// Main Inbox
var label = GmailApp.getUserLabelByName("Hold");
var threads = label.getThreads();
for (var i = 0; i < threads.length; i++)
{
var thread = threads[i];
thread.moveToInbox();
thread.removeLabel(label);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment