【问题标题】:Why does "category:social" with in GMail UI search, but does not work in GmailApp.search("category:social", 0, 500);为什么“category:social”在 GMail UI 搜索中使用,但在 GmailApp.search("category:social", 0, 500) 中不起作用
【发布时间】:2021-11-24 07:18:44
【问题描述】:

因此,将“category:social”放在 GMail UI 中会正确返回“社交”选项卡中的电子邮件。

输入const threads = GmailApp.search("category:social", 0, 500); 不会返回任何内容。

社交分类的电子邮件确实出现在const threads = GmailApp.search("category:updates", 0, 500);

我不明白 GMail 如何使用类别标签吗?

【问题讨论】:

    标签: google-apps-script gmail-api


    【解决方案1】:

    GMAIL UI 和 Apps 脚本搜索返回完全相同的结果

    您可以再次测试,例如修改您的代码如下并查看日志:

    function test(){
      const threads = GmailApp.search("category:social", 0, 500); 
      threads.forEach(function(thread){
      console.log(thread.getFirstMessageSubject())
      })
    }
    

    顺便说一句,您可以根据需要调整类别标签 - 无论是从 Gmail UI 还是 Gmail API

    您可以在打开电子邮件并单击标签图标时查看/编辑标签:

    【讨论】:

    • 谢谢,我在其他地方发现了一个影响起始索引号的错误。
    • 值得注意的是,如果请求的批处理中的剩余消息数 (max) 小于 start 索引号,则存在此行为的原因是 search(query, start, max) 将返回一个空数组。因此,在下面的示例中,如果剩余 9 条消息并且全部满足搜索条件,则返回将为空。谷歌文档:// Find starred messages with subject IMPORTANT and return second batch of 10. // Assumes there are at least 11 of them, otherwise this will return an empty array. var threads = GmailApp.search('is:starred subject:"IMPORTANT"', 10, 10);
    猜你喜欢
    • 2021-10-22
    • 1970-01-01
    • 2021-07-19
    • 1970-01-01
    • 1970-01-01
    • 2020-11-25
    • 2021-06-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多