1

One of the most annoying things with Gmail is that you can't sort the trash by when an e-mail was deleted. So if you accidentally delete an e-mail, miss the undo window, and you don't remember which e-mail, the only way to find the e-mail is go through our trash one-by-one.

Is there anyway to sort e-mails by when they were deleted or find e-mails by last deleted?

My solution right now involves using a Google Apps Script that runs every hour to tag untagged e-mails in the trash with the current month, day, and hour. That way I can minimize what I have to search through.

// 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);
}

What I end up with is e-mails in trash that are tagged like this:

  • 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 ...

While this works it is very hacky and does not seem very elegant. Is there a better way to accomplish what I am after -- being able to see when an e-mail was deleted so I can undelete e-mails I deleted accidentally.

IMTheNachoMan
  • 5,343
  • 5
  • 40
  • 89

1 Answers1

-1

My answer to this issue has been to avoid the "Delete" button and use "Archive" instead. When you "Archive" you can search for any deleted gmail using "Search".