gpt4 book ai didi

google-apps-script - 一次在 Gmail 线程中搜索多个未读标签的脚本

转载 作者:行者123 更新时间:2023-12-04 15:12:07 25 4
gpt4 key购买 nike

我有以下标签结构

+------------+------------+---------------+
| label | sub-label | sub-sub-label |
+------------+------------+---------------+
| 01-fruit | | |
| | 01-apples | |
| | | green |
| | | red |
| | 02-oranges | |
| | | red |
| | | orange |
| 02-veggies | | |
| | 01-peppers | |
| | | green |
| | | red |
+------------+------------+---------------+

正在使用的脚本是:

function mail2Sheets() {
var ss = SpreadsheetApp.getActive();
var sheet = ss.getSheetByName('newRec'); //get the sheet
var freshLabel = GmailApp.getUserLabelByName("00-fresh"); // in the end, add this label
const query = "label:unread" + " label:01-fruit";
var foundThreads = GmailApp.search(query);
var newReceipts = [];
for (var i = 0; i < foundThreads.length; i++) {

+++++++ SOME CODE HERE +++++++

}
}
if(!foundThreads.length) return; // if there are no unread ones, do nothing.
sheet.getRange(SpreadsheetApp.getActiveSheet().getLastRow()+1,2,newReceipts.length,newReceipts[0].length).setValues(newReceipts); //write to sheet
GmailApp.markThreadsRead(foundThreads); // mark "foundThreads" as read
freshLabel.addToThreads(foundThreads); // add label "00-fresh" to "foundThreads"
GmailApp.refreshThreads(foundThreads); // refresh "foundThreads" for changes to show
}

我可以成功搜索单个标签,例如:const query = "label:unread"+ "label:01-fruit";

还有。
尽管我有 GmailApp.refreshThreads(foundThreads); Execution 从未完成。
相反,它显示 Status Running

enter image description here

回顾

如何让查询同时搜索多个标签,例如
"label:unread"+ "label:00-fruit/01-apples/red"

"label:unread"+ "label:02-veggies/01-peppers/red"

还有。如何解决 Status Running 问题?

最佳答案

  • "" 是一个空格,用作 AND 运算符。
  • OR{} 可以用作 OR 运算符。

使用上述运算符,您的目标可以实现。

  • 当您想搜索带有label:unreadlabel:00-fruit/01-apples/red 的邮件时,请使用搜索查询作为如下。

    标签:未读标签:00-水果/01-苹果/红色

  • 当您想搜索带有label:unreadlabel:00-fruit/01-apples/redlabel:02 的邮件时-veggies/01-peppers/red,请按如下方式使用搜索查询。

      label:unread (label:00-fruit/01-apples/red OR label:02-veggies/01-peppers/red)
  •   label:unread {label:00-fruit/01-apples/red label:02-veggies/01-peppers/red}

引用:

关于google-apps-script - 一次在 Gmail 线程中搜索多个未读标签的脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65036762/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com