GMailApp Gmail search

瘦欲@ 提交于 2019-12-01 08:33:22

问题


I have a problem with the GmailApp search(query) function.

According to the manual it uses Gmail queries, so all the arguments should be accessible and return correct results.

This is my query:

var sent_threads = GmailApp.search('in:sent after:2016/02/29');

  Logger.log(sent_threads.length); // This one prints 21

  for (var i = 0; i < sent_threads.length; i++) {

    var message = sent_threads[i].getMessages()[0];
    var recipient = message.getTo();
    Logger.log(recipient); // This one prints 21 email recipients

  }

But when I go to the Gmail.com and type in the query in search bar I will get 44 messages. Any idea why those results are different?


回答1:


It's because the threads are collections of messages.

Try looping through the result of getMessages() instead of just accessing element [0].



来源:https://stackoverflow.com/questions/35730107/gmailapp-gmail-search

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!