【发布时间】:2019-01-29 15:21:52
【问题描述】:
Gmail 最烦人的事情之一是您无法根据电子邮件被删除的时间来分类垃圾箱。因此,如果您不小心删除了一封电子邮件,错过了撤消窗口,并且您不记得是哪封电子邮件,那么找到该电子邮件的唯一方法就是逐个翻阅我们的垃圾箱。
是否有按删除时间排序电子邮件或按上次删除时间查找电子邮件?
我现在的解决方案是使用每小时运行的 Google Apps 脚本来标记垃圾箱中未标记的电子邮件,并使用当前的月份、日期和时间。这样我可以最大限度地减少我必须搜索的内容。
// find all emails in trash that DON'T have the trashed_timestamps tag
var trashedEmailsThatAreNotTagged = GmailApp.search("in:trash -label:trashed_timestamps");
// only if we have emails that need to be processed
if(trashedEmailsThatAreNotTagged.length)
{
// get the month, day, and hour of right now
var now = Utilities.formatDate(new Date(), "EST", "MM dd HH").split(" ");
// tag those e-mails with the month, day, and hour
GmailApp.getUserLabelByName("trashed_timestamps/month-" + now[0]).addToThreads(trashedEmailsThatAreNotTagged);
GmailApp.getUserLabelByName("trashed_timestamps/day-" + now[1]).addToThreads(trashedEmailsThatAreNotTagged);
GmailApp.getUserLabelByName("trashed_timestamps/hour-" + now[2]).addToThreads(trashedEmailsThatAreNotTagged);
// add the main label so next time this code runs we can exlude these e-mails
GmailApp.getUserLabelByName("trashed_timestamps").addToThreads(trashedEmailsThatAreNotTagged);
}
我最终得到的是垃圾邮件中标记如下的电子邮件:
-
trashed_timestampsmonth-01day-28hour-19... -
trashed_timestampsmonth-01day-28hour-09... -
trashed_timestampsmonth-01day-27hour-22... -
trashed_timestampsmonth-01day-29hour-01...
虽然这行得通,但它非常 hacky 并且看起来不是很优雅。有没有更好的方法来完成我所追求的 - 能够查看电子邮件何时被删除,以便我可以取消删除意外删除的电子邮件。
【问题讨论】:
标签: google-apps-script gmail last-modified recycle-bin undelete