GMailApp Gmail搜索 [英] GMailApp Gmail search

查看:71
本文介绍了GMailApp Gmail搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

GmailApp搜索(查询)功能.

根据手册,它使用 Gmail查询,因此所有参数应该可以访问并返回正确的结果.

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

这是我的查询:

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

  }

但是,当我转到Gmail.com并在搜索栏中输入查询内容时,我会收到44条消息.知道为什么这些结果不同吗?

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?

推荐答案

这是因为线程是消息的集合.

It's because the threads are collections of messages.

尝试遍历getMessages()的结果,而不是仅访问元素[0].

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

这篇关于GMailApp Gmail搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆