Apps Developer Blog

Information for Google Apps Developers

Gmail Snooze with Apps Script

July 27, 2011
Share on Google+ Share on Twitter Share on Facebook
Google
Labels: Apps Script , Gmail APIs

65 comments :

Waqar Ahmad said...

Wow, i like it.. a very brilliant usage of apps script

July 27, 2011 at 3:37 PM
Hari said...

Does the app script run in the cloud or do you need to you have it open in a browser tab?

July 27, 2011 at 6:30 PM
Olivier Dagenais said...

Corey, what clock is used for the trigger? If it's UTC, then that might shift the snoozes at different times of the day throughout the globe (might be worth mentioning), but if it's "local" time for the user, then is the "midnight to 1am" selection guaranteed to only fire once when daylight saving time changes in autumn?

Cheers,
- Oli

July 27, 2011 at 6:54 PM
Daniel said...

Sweet. Can you implement these other features while you're at it: http://messymatters.com/email

July 27, 2011 at 6:54 PM
Anonymous said...

Can you guys please look into the spinning icon in my browser tab. It keeps spinning, Gmail never loads completely.

July 27, 2011 at 11:21 PM
dcsillag said...

Olivier, you can set the time trigger for whatever time you want it to run. See http://code.google.com/googleapps/appsscript/guide_events.html#TimeTriggers for details on how to set up the trigger.

Drew

July 28, 2011 at 6:23 AM
Yserbius said...

Nice. Thanks Chanoch. I never thought of using scripts to hack GMail.

July 28, 2011 at 1:31 PM
Yserbius said...

Thanks Chanoch! I didn't realize that you can run App Scripts in GMail. And congratulations on being quoted in Lifehacker.

July 28, 2011 at 1:32 PM
HockeyPhool said...

I'm able to create the script, but when I run the "setup" function I don't see any evidence that it's created the labels. I did authorize the script to modify my Gmail account.

July 28, 2011 at 1:35 PM
Albin Stööp said...

Really cool thought behind the actual script. I love the function, it's actually a pretty necessary function.

July 28, 2011 at 10:08 PM
Anonymous said...

the function is brilliant. i've always wanted an email tickler. THANKS!

July 29, 2011 at 6:20 AM
Michael said...

@Hari-Once you have told the message how many days to snooze it runs in the cloud and you do not need to have a browser tab open nor even have your computer on.
At setup you will create a once a day, time driven, trigger that resides on Googles computers(in the cloud) and will automatically update the snooze period on Googles computers.

July 29, 2011 at 8:09 AM
Michael said...

@Olivier Dagenais
Your local time zone is set up in the properties of the script editor when you create or upload the script. At setup you will also create a trigger from the script editor where you will specify what time of day or night you want the update snooze script to run.

July 29, 2011 at 8:15 AM
Anonymous said...

I ran the script but dont see the labels in Gmail...any ideas?

July 29, 2011 at 1:24 PM
Anonymous said...

I have followed the instructions, the script was enabled, but no labels were created in Gmail, even after reloading it completely.

If/when this will work, I can't wait to try to expand this, or make new great scripts :-)

July 29, 2011 at 1:45 PM
Saurabh Gupta said...

After you run the setup() function, you can refresh your inbox and you will see the labels. All labels are create under a label called Snooze.

Please post on Apps Script forum if you still need support.

http://www.google.com/support/forum/p/apps-script/

July 29, 2011 at 1:55 PM
lfobo said...

labels don't show up in Gmail, even though no error occurs during creation.

July 29, 2011 at 2:00 PM
Anonymous said...

Now the labels are there!
It took about 30 minutes to appear, maybe I was too excited to wait for them to appear, lol

July 29, 2011 at 2:14 PM
Reedy said...

Brilliant idea, but it doesn't work!
Ran through the install 3 times now, following it word for word, but same as other peoples comments - no labels were created, and no evidence that anything has changed...

July 29, 2011 at 2:16 PM
TerryKarges said...

I don't see the "setup" under the "Select a function to run" dropdown...am I doing something wrong?

July 29, 2011 at 2:57 PM
Michael said...

A couple of other sites with instructions that might help those having problems.

http://questioningtechnologyzerzan.blogmonster.de/2011/07/29/how-to-add-a-snooze-button-to-gmail-no-extensions-required-video/

http://www.ditii.com/2011/07/27/creating-gmail-snooze-extension-with-google-apps-script-code/

July 29, 2011 at 3:19 PM
Ryan Boyd said...

NOTICE TO ALL -

Definitely see Saurabh's comment above. Are you refreshing your Gmail window after running the setup() method?

Also, support can be handled much more easily via the forum. Please use that to get help with problems:
http://www.google.com/support/forum/p/apps-script/

Cheers,
-Ryan

July 29, 2011 at 3:33 PM
lfobo said...

it now worked for me. It is necessary to close all (!) running instances of gmail. I presume that leaving one gmail-tab open let the setup script fail in my case.

July 29, 2011 at 4:39 PM
deeps said...

awesome!! works for me

July 30, 2011 at 3:40 AM
Phil Simon said...

Like others, I followed the directions and the labels were not created. I'd love to find out when this works.

I'm running Chrome on Apple OSX 10.6

July 30, 2011 at 7:57 AM
Nathan Sudds said...

I'd recommend using Boomerang a Firefox/Chrome addon that does this and a lot more effortlessly --- 1 click install :)

www.boomeranggmail.com

July 30, 2011 at 8:31 AM
Oscar said...

I install last night but it not worked. How can I do now?

July 30, 2011 at 8:58 AM
Oscar said...

I installed last night but it not worked.
What can I do?

July 30, 2011 at 8:59 AM
VinceL said...

Nice work. I too was stymied for a moment when the labels didn't seem to appear. But having closed Gmail and re-run the setup. Everything looks right.

In Outlook-land, I usually just build a calendar appointment and drag my e-mail item into it, in order to get it out of my inbox (I'm an inbox zero fan, as well). But, that's not as convenient to do with Gmail/Gcalendar. This is a good solution!

July 30, 2011 at 11:21 AM
Thibaut said...

How do we disable that stuff ?

I installed it. I guess it worked since i had the new label.
Though, since i installed it, i have problems with gmail widgets on my android phone.

So, I want to remove that script now. But i don't know how i can do that. Don't know where the script is now.

Could anybody help me please ?

July 30, 2011 at 2:50 PM
Kenzo said...

Pretty nice, altough it makes the menu a bit too long. Now that I've tried it, I would like to unisnstall it. How can I do ?(I've deleted the project, but apparently it wasn't enough)

July 30, 2011 at 3:01 PM
Kenzo said...

A very nice feature, but now that I've tried it I would like to uninstall it. How do I do it?( I've tried to delete the project, but apparently it wasn't enough)

July 30, 2011 at 3:04 PM
DM said...

Instead of creating loads of labels, why not use the midnight event to add email IDs to the spreadsheet and then track the snooze progress in the spreadsheet each night. It would be a bit more complicated, but a lot neater and could be a nice example to build on.

July 30, 2011 at 4:27 PM
Peter Barganski said...

My Labels never got created and this morning I get the following error emailed to me:

Your script, Gmail Snooze, has recently failed to finish successfully. A summary of the failure(s) is shown below. To configure the triggers for this script, or change your setting for receiving future failure notifications, click here.

Details:

Start Function Error Message Trigger End
7/31/11 12:31 AM moveSnoozes TypeError: Cannot call method "getThreads" of null. (line 27) time-based 7/31/11 12:31 AM
Sincerely,

Google Apps Script

Need help? Visit the Google Apps Script documentation. Please do not reply to this message. (c) 2010 Google

Regards,

Peter

July 30, 2011 at 7:11 PM
mukteer.gaan said...

my 2 query

1. can i use it for any gmail account
2.i cannot find the stup button

please remember I am using chrome browser and I have 1474 filters to use

July 31, 2011 at 6:17 AM
DM said...

I have just written a spreadsheet based timer which allows you to set arbitrary dates in the future and customize the actions performed on expiration of the timer. I have applied to publish the code, but in the meantime you can view it here here.

July 31, 2011 at 6:37 AM
Anonsage said...

This is awesome! I've never used App Scripts before, but now I'm definitely planning a few more projects this summer with it. =D

July 31, 2011 at 8:26 AM
Mark said...

Start Function Error Message Trigger End
7/30/11 12:10 AM moveSnoozes TypeError: Cannot call method "getThreads" of null. (line 28) time-based 7/30/11 12:10 AM

July 31, 2011 at 10:15 AM
Alexander Nikolaev said...

Not working for me either. No labels created after running setup() and

TypeError: Cannot call method "getThreads" of null. (line 27)

error in my inbox.

August 1, 2011 at 2:21 AM
Saurabh Gupta said...

Please request support in our forum. Our community is very active.

http://www.google.com/support/forum/p/apps-script/

thank you
Saurabh

August 1, 2011 at 6:28 AM
Anonymous said...

My own implementation of snooze email reminders for to-do tasks using google apps script:
http://www.antoniorinaldi.it/build-your-own-pestering-email-reminder-using-google-docs/

August 1, 2011 at 7:04 AM
Peter Barganski said...

NO LABELS SOLVED!
Ok, so you have to actually save the Spreadsheet, and FIRST then Save the Script and run the Setup Trigger!

If you're like me, I had lots of triggers now so it Script Editior, go to Triggers -> All you triggers and delete all the old ones and recreate just the one.

August 1, 2011 at 11:54 PM
Thoughts of the Enigma said...

It works! But now I cannot find my script, I did not save the spreadsheet, I saved only the code and the trigger. Where can I find the script.

August 2, 2011 at 12:26 PM
Peter Barganski said...

The script is gonne - since t wasn't saved!

All that remains are the "triggers" which seem to be just like a schedule which points to a non existent script.

Create the spreadsheet and save it. Open script editor, cut and paste and save the script. I saved the spreadsheet at this stage too - making sure that the new script is save in it.

Then rerun setup trigger and you're all set!

Very strafe way of doing this spreadsheet/script dependancy - Google Developers - can this be recoded please.

August 2, 2011 at 4:56 PM
DM said...

I agree with Peter Barganski: the current relationship between spreadsheets and scripts is very odd.

Could you not elevate scripts to the level of "product", i.e. on equal terms with gmail, calender, docs, etc. Or at least on equal terms with docs-spreadsheet, docs-writer, and docs-presentations, etc.

Obviously this is quite a big change, but scripts have great potential and deserve their own fully-featured home!

August 2, 2011 at 5:19 PM
Gecoote said...

Hello,

I guess the instruction "oldLabel.getThreads(0, 100);" should be "oldLabel.getThreads(n, 100);" where you add n at each loop.
If not you are always looking to the first 100 items and it's never finishing.

Best regards

August 3, 2011 at 1:50 AM
Corey said...

Nope, the code is correct. The script moves all the threads in the "page" out of the oldLabel, so by the time you get to the next iteration of the loop, threads 0 to 100 are the next 100 threads. If you change it as you did, it will fail on threads 100-200 if you have that many snoozed.

August 3, 2011 at 7:10 PM
Badrumsrenovering said...

Does this awp work for ANY gmail acc?

And where can I set up this file?

August 6, 2011 at 8:16 AM
Markus said...

I try to install this last night but it didnt work so well.

What should I do know?

Thanks

August 9, 2011 at 6:39 AM
Mike Kakuk said...

mine is not working either....how do I delete and start over?

August 10, 2011 at 5:13 AM
Mroka said...

I cant get all the ones that say it dosent work and etc. Mine is working, fully.

Thanks anyway. Gmail rocks!

August 12, 2011 at 3:13 AM
Carey said...

I must have done something wrong, because I can't find the label in Gmail, and I get an email every day that the script is not working.

How do I delete it?

August 12, 2011 at 6:17 AM
Anonymous said...

You should buy boomerang and then it could be integrated tighter into gmail. And free. That would be awesome. Boomerang has a really nice, functional UI.

August 24, 2011 at 1:01 AM
Anonymous said...

Is there a way to set a filter for incoming messages to trigger a snooze to jump to the inbox? This might be a separate thing, unless there's a way to add it directly. Like if I want to snooze a message only until a different anticipated message arrives, could that happen. Only show this in inbox when message from z arrives?

August 28, 2011 at 10:11 PM
Badrumsrenovering said...

Works for me. Thanks :)

September 23, 2011 at 4:56 PM
Gå ner i vikt said...

Works great for me :)

October 13, 2011 at 9:35 AM
Rabatt Kampanjer said...

Well written and nice pictures. And the numbers are just growing every day... :)

December 5, 2011 at 2:05 PM
Ryan Boyd said...

@Rabatt - "Select All" + "Archive all" :)

December 5, 2011 at 3:13 PM
commet said...

I would love to find out how to automate the install to install an a user's gmail. Ofcourse, with the user's permission, but all the user should have to do is click on a link I have emailed them to run the Snoozes install.

Thanks Much JS

December 7, 2011 at 11:53 AM
My Piano's Muse said...

For everyone who had the following error:

"TypeError: Cannot call method "getThreads" of null. (line 29)"

I found one thing to check for that might fix it. In your script window, go to View>Execution Summary

It will tell you what tasks the script completed before crashing.

In my case, I noticed that it was stopping after 5. When I debugged it was getting null with a value of 5. It turns out, I had actually deleted the label for the 5th day. So when the script asks Gmail to pull up the 5th day label, instead of finding zero threads, it was finding null threads and crashing the script.

I created this 5th day label, and this script now works. Oops.

May 11, 2012 at 7:46 AM
My Piano's Muse said...

I was getting this error:

TypeError: Cannot call method "getThreads" of null. (line 29)

In my case, it turns out I had accidentally deleted the day 5 label. That's why, instead of pulling up zero threads, Gmail was pulling up null threads. It couldn't find the label.

May 11, 2012 at 7:48 AM
Tim said...

Could you please update this blog posting with how to remove the script for those of us who applied it? Something in the google Drive transition has deleted the script, yet still leaves us with daily messages like this one:

Date: Tue, 10 Jul 2012 17:30:18 -0700 (PDT)
Message-ID:
Subject: Summary of failures for Google Apps Script: Not found
From: [email protected]

Your script, Not found, has recently failed to finish successfully. A
summary of the failure(s) is shown below. To configure the triggers for
this script, or change your setting for receiving future failure
notifications, click here.
Details:


Start Function Error Message Trigger End

7/10/12 8:11 AM moveSnoozes We're sorry, a server error occurred. Please
wait a bit and try again. time-based 7/10/12 8:11 AM


Sincerely,
Google Apps Script

Need help? Visit the Google Apps Script documentation. Please do not reply
to this message. (c) 2012 Google

July 11, 2012 at 6:11 AM
Richard Morrison said...

Great idea, Google Scripts is going to be very useful.

I had another idea.

Use filters together with Gmail's "disposable" address feature to enable you to email yourself in the future.

E.g. [email protected]

October 3, 2012 at 1:44 PM
gmailsnooze said...

I took this script a little further and wrote a new one, which creates labels for the following 2 (or more) months, that you can snooze your mails. Take a look at it:

Gmail Snooze

February 26, 2013 at 7:31 AM
Diane Evans said...

I had high hopes for this, to effectively replicate "flag for follow up" from Outlook.

Sadly the first part of the description talks about messages, but it's actually threads which are being 'moved', given the APIs for assigning labels can only be applied to threads, and not messages.

I logged in this morning to 32 unread emails, for two actual messages I'd marked to snooze a couple of days back. It had picked up all the emails in the thread and applied accordingly.


So sadly this doesn't work for me.

June 27, 2013 at 3:40 AM

Post a Comment

  

Labels


  • .NET 3
  • #io15 1
  • Administrative APIs 26
  • Admin SDK 4
  • AdSense 1
  • analytics 4
  • Android 5
  • App Engine 5
  • Apps Script 98
  • Auth 1
  • billing 4
  • Charts 1
  • Chrome OS 1
  • classroom 1
  • Cloud Storage API 1
  • Community 1
  • Developers 5
  • Directory API 1
  • Drive 2
  • Drive SDK 38
  • execution API 1
  • Firebase 1
  • Freemium 1
  • Fusion Tables 2
  • Gadgets 5
  • Gmail APIs 16
  • Google+ 3
  • Google APIs 3
  • Google Apps 3
  • Google Apps Directory API 1
  • Google Apps Marketplace 3
  • Google Apps Script 1
  • Google Calendar API 20
  • Google Contacts API 3
  • Google Data Protocol 7
  • google docs 3
  • Google Docs API 20
  • Google Drive 2
  • Google Forms 4
  • Google I/O 3
  • googlenew 1
  • Google Prediction API 3
  • Google Profiles API 2
  • Google sheets 2
  • Google Sites API 4
  • Google Spreadsheets API 4
  • Google Talk 1
  • Google Tasks API 6
  • Groups 2
  • Guest Post 42
  • ISVs 2
  • java 1
  • JavaScript 3
  • marketing 3
  • Marketplace 47
  • Marketplace ISV Guest 21
  • Migration 1
  • Mobile 1
  • mpstaffpick 1
  • oauth 11
  • OpenID 7
  • PHP 1
  • python 4
  • realtime API 1
  • Resellers 2
  • Ruby 1
  • SaaS 1
  • security 1
  • Staff Picks 2
  • webinar 2


Archive


  •     2015
    • Oct
    • Sep
    • Aug
    • Jul
    • Jun
    • May
    • Apr
    • Mar
    • Feb
  •     2014
    • Dec
    • Oct
    • Sep
    • Aug
    • Jul
    • Jun
    • May
    • Mar
    • Feb
    • Jan
  •     2013
    • Dec
    • Nov
    • Oct
    • Sep
    • Aug
    • Jul
    • Jun
    • May
    • Apr
    • Mar
    • Feb
    • Jan
  •     2012
    • Dec
    • Nov
    • Oct
    • Sep
    • Aug
    • Jul
    • Jun
    • May
    • Apr
    • Mar
    • Feb
    • Jan
  •     2011
    • Dec
    • Nov
    • Oct
    • Sep
    • Aug
    • Jul
    • Jun
    • May
    • Apr
    • Mar
    • Feb
    • Jan
  •     2010
    • Dec
    • Nov
    • Oct
    • Sep
    • Aug
    • Jul
    • Jun
    • May
    • Apr
    • Mar
    • Feb

Feed

Company-wide

  • Official Google Blog
  • Public Policy Blog
  • Student Blog

Products

  • Android Blog
  • Chrome Blog
  • Lat Long Blog

Developers

  • Developers Blog
  • Ads Developer Blog
  • Android Developers Blog
  • Google
  • Privacy
  • Terms