[英]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.