Back to Gmail in Google Sheets
SheetXAI logo
Gmail logo
Gmail · Google Sheets Guide

Batch Delete Gmail Messages Matching a Search Query From a Sheet

2026-05-13
4 min read
See the Excel version →

The Scenario

You are a developer. You have a personal Gmail account that has accumulated 2,000+ automated notification emails from a CI/CD tool, all from the same sender. You know they are useless, you know they are older than 6 months, and you want them gone.

It is Saturday morning. You have an hour.

The bad version:

  • You open Gmail and search for the sender
  • Gmail shows 50 at a time
  • You select all 50, delete, go to next page, repeat
  • Gmail's "select all conversations that match this search" button appears — you click it
  • It selects all 2,000 but then the bulk delete stalls halfway through
  • You are not sure if 1,000 deleted or 400
  • You check Trash and there are 600 emails and you do not know what happened to the other 1,400.

The fast version is one prompt.

The Easy Way: One Prompt in SheetXAI

SheetXAI uses Gmail's batch delete API directly, so "delete all messages matching this search" is an atomic operation, not a page-by-page clicking exercise.

Open the SheetXAI sidebar and type:

Permanently delete all Gmail emails from 'notifications@github.com' that are older than 180 days. Tell me how many were deleted when the operation completes.

SheetXAI runs the search, collects all matching message IDs, calls Gmail's batch delete endpoint, and confirms the count. You did not click through a single page. The emails are gone.

What You Get

Every matching email deleted, with a confirmation count:

  • Deleted permanently — not moved to Trash, gone
  • Count confirmed — SheetXAI reports how many messages were removed
  • Atomic operation — the Gmail API batch delete runs in one call per batch, not one per message

If you want to move to Trash instead of permanent delete, say so in the prompt. SheetXAI will call the trash endpoint instead of delete. The behavior is explicit in your prompt, not a buried setting.

You can also ask SheetXAI to write the deleted message subjects to a sheet column before deleting, so you have a record.

What If the Data Is Not Quite Ready

Inbox cleanup operations usually have more nuance than a single sender delete.

When you want to preview the list before deleting anything

You want to see what will be deleted before you commit.

Search Gmail for all emails from 'notifications@github.com' older than 180 days. Write sender, subject, and date into columns A, B, and C of this sheet. Do not delete anything yet — I will review and then ask you to proceed.

When the delete scope should combine multiple criteria

You want to delete notifications from three different automated senders.

Permanently delete all Gmail emails from 'notifications@github.com', 'noreply@jira.com', or 'noreply@sentry.io' that are older than 90 days. Report the count deleted per sender.

When you want to trash emails with a specific label instead of by sender

You have a "Newsletters" label applied to many senders. You want to clean it all at once.

Move all Gmail emails with the label "Old-Newsletters" to Trash. There are approximately 500 of them. Report the count when done.

When you want to log what was deleted and then delete it in one pass

You want a paper trail for the deletion, in case you need to explain to someone why something is missing.

Search Gmail for all emails from 'notifications@github.com' older than 180 days. First, write the sender, subject, and date for each one into columns A through C of this sheet. Then permanently delete all of them. Write the final count of deleted emails into cell E1.

The pattern: describe the scope and the action in plain English, and SheetXAI handles the API calls. Scale does not change the prompt.

Try It

Get the 7-day free trial of SheetXAI and open any sheet, then tell it which Gmail messages to clean up and how. The Gmail integration is included in every SheetXAI plan. For related workflows, see how to audit Gmail filters into a sheet or the Gmail in Google Sheets overview.

Stop memorizing formulas.
Tell your spreadsheet what to do.

Join 4,000+ professionals saving hours every week with SheetXAI.

Learn more