TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

How to bulk delete emails from Gmail

2 pointsby atum478 months ago
Just saw a post about a service that provides, among other things, bulk email deletion on Gmail; but you have to give them access to your account (Yeah, that&#x27;s a NO for me dog). Coincidentally, not so long ago I was talking to ChatGPT about how to do just that (I reckon that ChatGPT has read every manual and API documentation in existence). Anyways, here&#x27;s the tutorial that it gave me and that I have tested.<p>Steps:<p>1. Open Google Apps Script (drive.google.com &gt; new &gt; more &gt; Google Apps Scripts)<p>2. Click create scripts.<p>3. Write the Script:<p><pre><code> function deleteOldEmails() { var threads = GmailApp.search(&#x27;older_than:1y&#x27;); for (var i = 0; i &lt; threads.length; i++) { threads[i].moveToTrash(); } } </code></pre> This example deletes emails older than one year (older_than:1y). You can modify the search query for different criteria (e.g., label:unread, from:specific@example.com, before:YYYY&#x2F;MM&#x2F;DD).<p>4. Save the Script.<p>5. Run the Script:<p>Click the play icon to run the script. It will ask for permissions the first time.<p>This method allows you to automate email management using custom queries.<p>If you want to test the search string - GmailApp.search(...) - to be sure you are deleting the right emails, you can use the filter on the search bar on Gmail.

1 comment

m9a4r3a3n8 months ago
Thanks, i was trying to download some of emails lately. After slamming some keys i found takeouts manages downloading data throughout google services. But this feels more interesting, i’ll see if i could download them with this!
评论 #41747813 未加载
评论 #41747758 未加载