[英]Delete gmails with script using google sheet with gmail search terms and multiple rows in sheet for bulk processing
This function will delete ONE (1) email matching search term defined in A2 (And it works):此 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());
}
However, creating individual script functions for individual search terms with individual triggers would take forever to do...但是,为带有单独触发器的单独搜索词创建单独的脚本函数将需要很长时间才能完成......
I tried simply to use A2:A, but unfortunately that was not working.我尝试简单地使用 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());
}
How can one delete gmails with a script using google sheet scripts with gmail search terms and multiple rows in a sheet for bulk processing?如何使用带有 gmail 搜索词和工作表中的多行进行批量处理的谷歌工作表脚本删除 gmail?
3 parameters are needed: sender, subject and older_than, like this:需要 3 个参数:sender、subject 和 old_than,如下所示:
from:(@google.com) subject:Notification older_than:3d来自:(@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.