ChatGPT just helped me solve a big Gmail problem – and I’ve finally reached inbox zero

9 hours ago 40
Two laptop screens showing Gmail and the ChatGPT logo
(Image credit: Shutterstock / Voar Designs / Google)

ChatGPT is wrong a lot of the time, but the reason why millions of us use it is because, when it gets things right, there isn't really anything else quite like it.

I had that experience recently when wrestling with a seemingly simple Gmail problem. In short, my inbox was out of control, well into six figures for unread messages – and the mere presence of that number was a daily reminder of my poor housekeeping.

None of those unread emails were particularly important. I'd been labeling and replying to key ones, and using filters to surface the must-reads. But I'd let the weeds completely overwhelm the Gmail flower bed, and it was high-time I got the trowel out.

No problem, I thought, I'll just take the nuclear option and do a giant 'select all' and 'mark all as read' to give me a clean slate. Except doing that, in many variations, didn't work. Gmail, it seems, has a secret internal limit for bulk operations, and I was way over that figure.

Even doing it in batches using Gmail's search operators wasn't working. My ridiculous inbox had seemingly broken Gmail's brain, and Google was unable to help.

Fortunately, this is where a tool that I now treat like an eccentric uncle (incredibly smart in some ways, worryingly mistaken in others) came to the rescue...

Going off script

I've found ChatGPT to be most helpful when it's taken my poorly-worded prompt and come up with a solution that would have never crossed my mind in a million years. Usually, this involves coding.

Sign up for breaking news, reviews, opinion, top tech deals, and more.

For my Gmail problem, it suggested using Google Apps Script. This platform is something I'd never heard of (partly because it's a Google Workspace thing), but it's apparently a bit of an unsung hero for automating simple tasks, particularly in apps like Docs, Sheets and Gmail.

People use Gmail Apps Script, I've since learned, to automate all sorts of things, from business admin to sweepstake spreadsheets for friends. But it was also the trick I needed to get around Gmail's stubborn limits for bulk operations.

A laptop screen showing some code in Google Apps Script

(Image credit: Google)

After the usual back-and-forth with ChatGPT, it refined a small script that searched my Gmail inbox in chunks of 500 unread threads and marked them as 'read', until I hit the 'inbox zero' nirvana I'd assumed it would be much simpler to reach.

The process was as simple as going to Google Apps Script, clicking 'New Project', pasting in the script (which ChatGPT assured me was "fully balanced and tested"), clicking the 'Save' icon, then hitting the 'Run' button. The script began whirring away in the background and I watched my inbox slowly tick down to zero.

How do you use ChatGPT?

ChatGPT doesn't get its wisdom from nowhere and I've no doubt that its Gmail solution (maybe large parts of the script itself) were 'inspired' by threads from the likes of Stack Overflow and Google Support.

The thing is, Googling didn't surface any of them and I was left running around in circles before ChatGPT intervened. The other big strength of chatbots (again, when they get things right) is that they're able to tailor solutions and code to your exact situation.

That doesn't mean you don't have to double-check everything they say, and I did have a small amount of trepidation in running a script I didn't fully understand on my Gmail account. But after scanning the very basic code for anything troublesome, I was happy to give it a spin – and I'm glad I did.

An iPhone on a blue and green background showing the ChatGPT app producing code for Google Apps Script

(Image credit: OpenAI / Apple)

For me, this slightly dry but useful exercise summed up how I currently use chatbots like ChatGPT, and it seems I'm in the majority. A recent study highlighted by Search Engine Land suggests that a massive 95% of ChatGPT users still use Google – in other words, the chatbot is a supplement to Google rather than a replacement.

ChatGPT is, as I mentioned earlier, that eccentric, sometimes genius uncle I go to with thorny problems that I just can't solve using pre-chatbot techniques. And while I certainly don't trust his recall of news events (a recent BBC study found that 45% of AI chatbot answers around news had a "significant issue"), I'll always come back to him for those flashes of inspiration.

If you're in a similar Gmail inbox conundrum to me and want to try a (possibly over-engineered) solution to reach inbox zero, here's the Google Apps Script code that worked for me (thanks, ChatGPT). My only challenge now is staying there.

function markAllAsReadSafe() { var searchBatchSize = 500; // how many threads to request from Gmail at once var apiMax = 100; // GmailApp.markThreadsRead accepts at most 100 threads per call var totalMarked = 0; do { // get up to searchBatchSize unread threads (newest first) var threads = GmailApp.search('is:unread', 0, searchBatchSize); if (threads.length == 0) break; // process in sub-batches of apiMax for (var i = 0; i < threads.length; i += apiMax) { var slice = threads.slice(i, i + apiMax); try { GmailApp.markThreadsRead(slice); totalMarked += slice.length; } catch (e) { Logger.log('Error marking threads read for slice starting at ' + i + ': ' + e); // pause briefly and continue Utilities.sleep(2000); } // small pause to reduce chance of throttling Utilities.sleep(500); } Logger.log('Marked ' + totalMarked + ' threads so far.'); // loop continues if Gmail returned a full batch (means there are probably more) } while (threads.length === searchBatchSize); Logger.log('Finished. Total threads marked read: ' + totalMarked); }

Follow TechRadar on Google News and add us as a preferred source to get our expert news, reviews, and opinion in your feeds. Make sure to click the Follow button!

And of course you can also follow TechRadar on TikTok for news, reviews, unboxings in video form, and get regular updates from us on WhatsApp too.

Mark is TechRadar's Senior news editor. Having worked in tech journalism for a ludicrous 17 years, Mark is now attempting to break the world record for the number of camera bags hoarded by one person. He was previously Cameras Editor at both TechRadar and Trusted Reviews, Acting editor on Stuff.tv, as well as Features editor and Reviews editor on Stuff magazine. As a freelancer, he's contributed to titles including The Sunday Times, FourFourTwo and Arena. And in a former life, he also won The Daily Telegraph's Young Sportswriter of the Year. But that was before he discovered the strange joys of getting up at 4am for a photo shoot in London's Square Mile. 

Read Entire Article