GmailApp Gmail 搜索 [英] GMailApp Gmail search

查看:19
本文介绍了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天全站免登陆