繁体   English   中英

使用带有 gmail 搜索词和工作表中的多行的 Google 表格删除带有脚本的 gmail,以进行批量处理

[英]Delete gmails with script using google sheet with gmail search terms and multiple rows in sheet for bulk processing

此 function 将删除 A2 中定义的一 (1) 个 email 匹配搜索词(并且有效):

function deleteEmail() {
  const ss = SpreadsheetApp.getActiveSpreadsheet();
  const sheet = ss.getSheets()[0];
  const searchTerm = sheet.getRange("A2").getValue();
  GmailApp.search(searchTerm).map(thread => thread.moveToTrash()); 
}

但是,为带有单独触发器的单独搜索词创建单独的脚本函数将需要很长时间才能完成......

我尝试简单地使用 A2:A,但不幸的是这不起作用。

function deleteEmail() {
  const ss = SpreadsheetApp.getActiveSpreadsheet();
  const sheet = ss.getSheets()[0];
  const searchTerm = sheet.getRange("A2:A").getValue();
  GmailApp.search(searchTerm).map(thread => thread.moveToTrash()); 
}

如何使用带有 gmail 搜索词和工作表中的多行进行批量处理的谷歌工作表脚本删除 gmail?

需要 3 个参数:sender、subject 和 old_than,如下所示:

来自:(@google.com)主题:通知old_than:3d

也许这会奏效

function deleteEmail() {
  const ss = SpreadsheetApp.getActiveSpreadsheet();
  const sheet = ss.getSheets()[0];
  const terms = sheet.getRange("A2:A" + sheet.getLastRow()).getValues();
  terms.forEach(s => Gmail.App.search(s).forEach(thread => thread.moveToTrash()))
}

暂无
暂无

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

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