What Archively does is scan for labels that instruct it to archive and/or delete emails. There are two top level labels, namely, "delete" and "arkive" (the label "archive" is reserved by Gmail). To archive, the label should be nested under "arkive", with a name like "in 5 days". To the Google Apps Script, the label will look like "arkive/in 5 days". Here are some examples of labels that are understood by Archively:
- arkive/at EOD this will archive the message/thread just after midnight (at End Of Day).
- arkive/at EOD+1d this will archive the message/thread after midnight the following day (at End Of Day plus one more day).
- arkive/when 7wks old will archive the message/thread when the last message in the thread is 7 weeks old. If any new messages arrive (in this thread), it will have to wait till the latest message is 7 weeks old.
- delete/in 2 weeks will delete the message/thread two weeks after the label is spotted.
- delete/on 3 Feb 2014 will delete the message/thread at 12 AM (00:00) on the specified date.
- delete/on 3 Feb 2014 9:00 will delete the message/thread within an hour after the specified time (I recommend that the script only runs once an hour).
- There are a few more examples listed at the top of the source code.
One of the main ways I am using Archively for is via a filter. One of the filters I have picks out marketing style emails with a specific keyword in it, and then labels the email with delete/at EOD+2d. To get Archively working for you, follow these easy steps:
- Copy the text out of my copy of the script here or here.
- Go to Google Drive and create a new Script. If you don't see a "Script" option, you'll need to choose "Connect more apps" and then pick Google Apps Script (also says "Script in Google Drive").
- In the new Script, paste in the text that was copied in step 1.
- Do a test run if you want: Select the checkEmAll function and run it.
- Select menu Resources > Current project's triggers. Add a trigger to run checkEmAll hourly, and cleanDbRecords weekly (or some other frequencies as desired).
- At some point you'll need to authorise the script to work with your Gmail account.
- From within Gmail, create the base labels delete and arkive. Then you will easily be able to create labels nested under them.
- Now you can apply labels directly, or set up filters to apply Archively labels for you.
LabelText = "delete/" | "arkive/", TimeSpec;
TimeSpec = EndOfSpec | AgeSpec | WhenSpec | FromNowSpec;
EndOfSpec = "TOMORROW"
| (["AT", {" "}], "EO", "D"|"W"|"M"|"Y"|"FY", {TimeSpan});
Tomorrow is an alias for EOD. The end of day (D), week (W), month (M), year (Y) and financial year (FY) are available. A month is defined as 31 days.
AgeSpec = ["WHEN "], {TimeSpan}, " OLD";
WhenSpec = "ON ", JavaScriptDate;
The description of JavaScriptDate is left to the Internet. DateTimes such as "14 Jan 2014", and "14 Jan 2014 11:00" should work just fine.FromNowSpec = ["IN "], {TimeSpan};TimeSpan ={" "}, ["-"|"+"], {" "}, Number, {" "}, TimeUnit;
TimeUnit = ("H", ["R" | "RS" | "OUR" | "OURS"])
| ("D", ["AY" | "AYS"])
| ("W", ["K" | "KS" | "EEK" | "EEKS"])
| ("M", ["ONTH" | "ONTHS"])
| ("Y", ["R" | "RS" | "EAR" | "EARS"]);
Number = (Digit, {Digit}, [".", {Digit}])
| (".", Digit, {Digit});
Digit = "0"|"1"|"2"|"3"|"4"|"5"|"6"|"7"|"8"|"9";
Archively by Jonathan Johansen is licensed under a Creative Commons Attribution 4.0 International License.