Skip to content

Instantly share code, notes, and snippets.

@EXJUSTICE
Created August 30, 2017 20:00
Show Gist options
  • Save EXJUSTICE/73b42c05f918f7020af9add7b3b8e51a to your computer and use it in GitHub Desktop.
Save EXJUSTICE/73b42c05f918f7020af9add7b3b8e51a to your computer and use it in GitHub Desktop.
function myFunction() {
var comparison ="test";
var ureadMsgsCount = GmailApp.getInboxUnreadCount()
if(ureadMsgsCount>0)
{
var threads = GmailApp.getInboxThreads(0, ureadMsgsCount);
for(var i=0; i<threads.length; i++)
{
if(threads[i].isInInbox())
{
//Make an array to hold messages
var messages = threads[i].getMessages();
for(var j=0; j<messages.length; j++)
{
var subject = messages[j].getSubject()
//Fetched subject, do comparison, if success then reply and delete
if(subject ==comparison){
threads[i].reply("SUCCESS");
threads[i].moveToTrash();
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment