简体   繁体   English

从Gmail.Thread获取多条消息

[英]Get more than 1 message from Gmail.Thread

When i run this script, i get 1 from adress, i would like to get the first 5 from adresses i try to set GmailApp.getInboxThreads(0, 5)[0]; 当我运行此脚本时,我从地址中获取1,我想从地址中获取前5个,我尝试设置GmailApp.getInboxThreads(0, 5)[0]; but that does not work, what do i need to do if i need to have 5 or more? 但这不起作用,如果我需要5个或更多,该怎么办? Now it only process 1 mail/thread. 现在,它仅处理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());
 }
}

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());

=) =)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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