【问题标题】:undelete Gmail e-mails by when they were deleted and/or sort trash by when an email was deleted按删除时间删除 Gmail 电子邮件和/或按删除电子邮件时间对垃圾进行分类
【发布时间】: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_timestamps month-01 day-28 hour-19 ...
  • trashed_timestamps month-01 day-28 hour-09 ...
  • trashed_timestamps month-01 day-27 hour-22 ...
  • trashed_timestamps month-01 day-29 hour-01 ...

虽然这行得通,但它非常 hacky 并且看起来不是很优雅。有没有更好的方法来完成我所追求的 - 能够查看电子邮件何时被删除,以便我可以取消删除意外删除的电子邮件。

【问题讨论】:

    标签: google-apps-script gmail last-modified recycle-bin undelete


    【解决方案1】:

    我对这个问题的回答是避免使用“删除”按钮,而是使用“存档”。当您“存档”时,您可以使用“搜索”搜索任何已删除的 gmail。

    【讨论】:

    • 但是如果你不记得存档的内容,不小心说出来,那么你还是找不到。
    猜你喜欢
    • 2017-05-14
    • 2023-03-17
    • 2017-01-04
    • 2015-07-25
    • 1970-01-01
    • 1970-01-01
    • 2011-03-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多