Archives any email sent to me in gmail from an address previously identified as a recruiter
Use this when you're getting a variety of emails from a variety of senders that you don't exactly want to mark as spam or delete, but that don't need your attention.
Job recruiters are difficult to create basic filters for because they aren't coming from any pattern of addresses, nor do they all use the same key words in their subject or bodies.
If you're getting emails from a single sender or domain, just use the built-in gmail filters instead.
- Gets a list of N most recent sender email addresses in a gmail label
- Scans the inbox for any new emails from the same senders, then
- applies the label to the email
- marks it as read
- archives it
- Logs the sender and subject of any email the script archived
Any gmail label containing emails where you would want followup emails filtered. Defaults to running against the Recruiters
label.
I wrote the code, but when you copy paste the code into google scripts, you take full ownership of what the code is doing on your account. Make sure you understand what the code does before you press run. Feel free to report any bugs or make pull requests. I will not assist in recovering any data. This code will never send any data outside the context in which it runs.
- Go to https://script.google.com
- Click "New Project"
- Copy the contents of this repo's Code.gs into your new project's "Code.gs" file
- If you have a custom label, edit the
const labelName = "Recruiters";
line to contain the name of your label
- If you have a custom label, edit the
- Rename your project to something descriptive, e.g.
Filter Recruiters
- Make sure
archiveRecruiters
is the selected function to run - Save your changes with
ctrl+s
orcmd+s
- Allow the code to access your inbox
- Press the "Run" button at the top to start execution
- A popup will appear asking for you to allow the code to access your data, press "Review permissions"
- Select the account
- Click "Advanced"
- Click "Go to {project_name} (unsafe)"
- Click "Allow"
- All emails processed by the script (or any errors that occurred) will appear in the "Execution log" down below
After following the first time setup above, you can run the script on a timer.
- Click "Triggers" on the far left of the project dashboard (button with the alarm clock icon)
- Click "Add Trigger"
- Fill out the form as follows:
- Function:
archiveRecruiters
- Deployment:
Head
- Event source:
Time-driven
- Type: I use
Hour timer
- Interval:
Every hour
- Failure notification settings: I recommend
Notify me immediately
so you can stop future execution if you encounter failures.
- Function:
You can run it more frequently if you want but because the script doesn't yet cache recruiter email addresses, I recommend not running it more frequently than once an hour