Created
March 2, 2014 00:08
-
-
Save colinloretz/9299685 to your computer and use it in GitHub Desktop.
AwaitingReply
This file contains 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
function label_awaiting_reply() { | |
var emailAddress = Session.getEffectiveUser().getEmail(); | |
Logger.log(emailAddress); | |
var EMAIL_REGEX = /[a-zA-Z0-9\._\-]+@[a-zA-Z0-9\.\-]+\.[a-z\.A-Z]+/g; | |
var label = GmailApp.createLabel("AwaitingReply"); | |
var d = new Date(); | |
d.setDate(d.getDate() - 7); | |
var dateString = d.getFullYear() + "/" + (d.getMonth() + 1) + "/" + d.getDate(); | |
threads = GmailApp.search("in:Sent after:" + dateString); | |
for (var i = 0; i < threads.length; i++) | |
{ | |
var thread = threads[i]; | |
var lastMessage = thread.getMessages()[thread.getMessageCount()-1]; | |
lastMessageSender = lastMessage.getFrom().match(EMAIL_REGEX)[0]; | |
if (lastMessageSender != emailAddress) | |
{ | |
thread.addLabel(label); | |
Logger.log(lastMessageSender); | |
} | |
} | |
} | |
function doGet(e){ | |
label_awaiting_reply(); | |
} |
Also, the fact that this whole thing works was kind of amazing to me since it never appears to ask for permission to Google Mail from Google Docs....
To get scripts go to connect more apps when you click create and search for script.
I got lost after step 5.
I clicked "update" then
Resources -> current projects triggers
From there I set it to run every hour. I also ran it manually once. When I manually ran it it asked me for permissions.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Disclaimer: I did not write the above code. I believe I ran across it on Fred Wilson's blog years ago when he was talking about email productivity but haven't managed to find who and where it was posted.
What it does
Marks an emails that you have received but you have not responded to with an "AwaitingReply" label in gmail. Sometimes having "unread" and "read" emails isn't enough.
It's not perfect but it will help you find some needles in the haystack when you're dealing with large email loads. When I was in TechStars we were doing a lot of follow up emails with mentors and investors and we used this frequently to make sure we didn't have any we were missing.
How to use it
Edit this and use it as you you need. This is a good example for one use case but you can use the attached code to create labels for other situations as well, such as tagging all emails that you are waiting to hear back from.