2014-10-10 67 views
0

當我運行此腳本時,我從地址獲得1,我想從地址獲得前5個我嘗試設置GmailApp.getInboxThreads(0, 5)[0];但這不起作用,我需要什麼如果我需要5個或更多?現在它只處理1個郵件/線程。從Gmail獲取1條以上的郵件。線程

// log the sender of the messages in the thread 
var firstThread = GmailApp.getInboxThreads(0, 1)[0]; 
var messages = firstThread.getMessages(); 
for (var i = 0; i < messages.length; i++) { 
    Logger.log(messages[i].getFrom()); 
} 
} 

回答

0

Got it!

var threads = GmailApp.getInboxThreads(0, 5); 
    for (var i = 0; i < threads.length; i++) { 
    var message = threads[i].getMessages()[0]; 
    Logger.log(message.getFrom()); 

=)