Last active
December 17, 2015 14:48
-
-
Save amityweb/5626648 to your computer and use it in GitHub Desktop.
Receive GMail Email at a Specified Time
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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