TypeError:无法在对象GmailMessage中找到函数getFrom

时间:2017-11-02 17:37:13

标签: javascript google-apps-script google-apps-marketplace

我在Google Apps脚本中有以下功能:

function getMail() {
   var threads = GmailApp.getInboxThreads(0, 50);
   var messages = GmailApp.getMessagesForThreads(threads); 
   var froms = [];
   for (var i=0; i<messages.length; i++) {
       var msg = messages[i];
       Logger.log(msg.getFrom());
   }
}

getMessagesForThreads返回GmailMessage对象列表。 那么为什么不能访问getFrom方法?

1 个答案:

答案 0 :(得分:0)

function getMail() {
    var threads = GmailApp.getInboxThreads(0, 50);
    var messages = GmailApp.getMessagesForThreads(threads); 
    for (var i=0; i<messages.length; i++) {
        for (var j=0; j<messages[i].length; j++) {
            Logger.log(messages[i][j].getFrom());
        }
    }
}

getMessagesForThreads返回GmailMessage[][]而不是像我想象的那样GmailMessage[]