Every day, you receive tens of emails in your inbox—not only important emails but also unimportant emails such as promotional emails. Have you found it difficult to filter these unimportant emails? In this article, I go through how to filter unimportant emails from your Gmail inbox using Gemini 2.5 Flash and Google Apps Script. Before getting started, you will need a Google account.
Step-by-Step Guide
Step 1: Search Unimportant Emails from Your Inbox
First, you will need to get all unread emails.
- Visit my Google Apps Script project.
- Click "Run."
Source: https://script.google.com
- A pop-up will be opened. Click "Review permissions."
Source: https://script.google.com
- Sign in to your account.
- Another pop-up will be opened. Click "Advanced."
Source: https://account.google.com
- Click "Go to Email Search in Gmail (unsafe)."
Source: https://account.google.com
- The final consent page will be opened. Scrolling down the section, you will see the button "Continue." Click it.
Source: https://account.google.com
- The script will be executed.
- Copy this entire log.
Source: https://script.google.com
Step 2: Identify and Delete Unimportant Emails
After you get all unread emails' subjects and bodies. Let's find out what is unimportant with Gemini 2.5 Flash.
- At first, since your emails are personal information, you will need to opt out your chats from the machine learning of Google Gemini. For the guide, follow Step 2 in this article below.
Also ReadHow to Create a Software User Manual with AI
- Go back to https://gemini.google.com.
- Make sure the model used is 2.5 Flash.
Source: https://gemini.google.com
- Enter this prompt template in the center textbox.
[Task]: Create a search query to filter unimportant emails. [Inbox Emails]: (paste the copied email data here) [Constraints]: - Output must only be a single copyable code snippet. ```text (command here) ```
- Fill bold placeholders enclosed with "(" and ")" in the prompt.
- Click Enter.
- Click the button with the 2 layered squares to copy the generated command.
Source: https://gemini.google.com
- Visit https://mail.google.com.
- At the top center of the page, you will see the search box. Paste the copied command.
Source: https://mail.google.com
- Click Enter.
- The search result will be returned. Check if the returned emails are deletable. If ok, delete them.
Pros and Cons of the AI Inbox Decluttering
Pros
In-Bulk Processing
One Redditor said, "In my previous startup, managing my inbox was a constant headache." This is a real voice that represents pain points most people have. The Redditor was also spending more time sorting emails than on their actual business. Sorting emails can be hard as the number of emails being sorted increases. You need to clean emails before actually sorting. To help with this, this AI decluttering is here. Do this every day for cleaning, and process the remainings by batches on every weekend.
Time-Saving Approach
The same Redditor said, "Time is one of our valuable assets." If you agree with this statement, I think you should use this AI solution. The reason is that it usually takes less than 5 minutes and thus helps us focus on top priority. As a result, your time on email processing will be reduced.
Reduced Mental Burnout
Staring at an overflowing inbox triggers decision fatigue and mental burnout. This AI email decluttering technique automatically filters out promotional noise and unimportant messages in under 5 minutes daily. By removing email clutter, you recover mental clarity to focus on high-priority work instead of sorting endless emails. As a result, you will be free from inbox-induced overwhelm and burnout.
Cons
Email Mis-deletion
As you know, AI is not perfect and can accidentally delete important emails. Nevertheless, you still have a workaround for this. You can still restore the deleted within 30 days. So, I think it's worth trying.
Incomplete Search Query
If the number of your emails is many, Gemini may rush to meet your request quickly and return an error-prone search query. If this happens, add this additional prompt below the "[Task]" section for Gemini to generate responses with chain-of-thought.
[Workflow]: 1. Determine all unimportant emails. 2. Generate a search query to filter them. 3. Return only the code snippet.
Potential Personal Data Breach
In most cases, emails contain your or your clients' personal information. It means you may put those data at significant cybersecurity risks. That's something bothering you, isn't it? So, I take robust measures to this risk. My Google Apps Script limits your email data to only unread emails in the inbox, and Google Gemini's opt-out function will delete your chat after 72 hours. This lowers the risk of data breaches to Google as well as the other third parties.
FAQ
How Can I Find the Search Result of My Emails?
After you execute the email search script, you can find the search result under "Execution Log."
Will Executing This Script Leak My Personal Data?
No, in the first place, I can't look at your execution result from my account. In fact, your information will be stored in your account.
How Long Will My Data Sent to Google Gemini Keep?
Your data will be kept for 72 hours for Gemini to respond to you safely.
What're the Pros and Cons of This AI Hack?
The Pros include batch processing, big time-saver, and ligthened mental burnout, while the cons are mis-deletion of important emails, an error-prone search query, and personal data leakage risk.
To conclude, in this article, you learned how to save your inbox from flooding emails using Gemini 2.5 Flash, Google Apps Script, and Gmail. If you want AI to write your emails, this article will help you with this.

- https://www.reddit.com/r/SaaS/comments/1fan75b/whats_your_biggest_pain_point_when_it_comes_to/
Comments
Post a Comment