Skip to content

Instantly share code, notes, and snippets.

@tskrynnyk
Created November 27, 2012 18:25
Show Gist options
  • Select an option

  • Save tskrynnyk/4156048 to your computer and use it in GitHub Desktop.

Select an option

Save tskrynnyk/4156048 to your computer and use it in GitHub Desktop.
Gmail Notify
function EmailNotify() {
var label = GmailApp.getUserLabelByName('Notify');
var threads = label.getThreads();
for (var x in threads) {
var messages = threads[x].getMessages();
for (var i = 0; i < messages.length; i++) {
var message = messages[i];
if (message.isUnread()){
var emailAddressForNotify = 'qwerty@plusnet.pl';
//Logger.log(message.getFrom());
GmailApp.sendEmail(
emailAddressForNotify,
message.getFrom() + ' ' + message.getSubject(),
'Notification of new message.'
);
}
}
}
label.removeFromThreads(threads);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment