Created
August 30, 2017 20:00
-
-
Save EXJUSTICE/73b42c05f918f7020af9add7b3b8e51a to your computer and use it in GitHub Desktop.
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
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