简体   繁体   中英

getInboxThreads() for specific inbox folder. Google Apps Script gmail

I am trying to retrieve email threads from only a specific folder which I named 'Approval_needed'. I have found a way to get all of my inbox threads like so from the Google Apps Script Reference page :

var threads = GmailApp.getInboxThreads();
 for (var i = 0; i < threads.length; i++) {
   Logger.log(threads[i].getFirstMessageSubject());
 }

Is it possible to do something like getInboxThreads for folder 'Approval_needed' ?
I have searched around and have not found an answer for this. I have found other methods such as getPriorityInboxThreads() and getStarredInboxThreads() , but nothing like getInboxThreads(string) .

What you are calling "folder" is actually a "label" in gmail, you can use the getThreads() method on the Label class.

Example from the documentation :

// Log the subject lines of the threads labeled with MyLabel
 var label = GmailApp.getUserLabelByName("MyLabel");
 var threads = label.getThreads();
 for (var i = 0; i < threads.length; i++) {
   Logger.log(threads[i].getFirstMessageSubject());
 }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM