# Tips, tricks and scripts for automating your Gmail inbox with Google Apps Script

This is a repost of an [editorial piece I shared on AppsScriptPulse](https://pulse.appsscript.info/p/2022/05/tips-tricks-and-scripts-for-automating-your-gmail-inbox-with-google-apps-script/)

One the powerful features of Google Apps Script is with a couple of lines of code you can quickly start automating and organising your inbox. For people just getting started with Apps Script Google provide a introductory codelab [‘Accessing Google Sheets, Maps, and Gmail in 4 lines of code!’](https://codelabs.developers.google.com/codelabs/apps-script-intro#0) and for those wanting to do a bit more the Google Workspace Developer documentation includes a ‘[create a mail merge](https://developers.google.com/apps-script/samples/automations/mail-merge)‘ solution.

> Mail merge solutions are bit or a reoccurring theme in the world of Google Apps Script. In 2011 the official G Suite Developers Blog featured [4 ways to do Mail Merge using Google Apps Script](https://gsuite-developers.googleblog.com/2011/10/4-ways-to-do-mail-merge-using-google.html) with community contributions from James Ferreira, Steve Webster and Romain Vialard. The post references Romain’s ‘Yet another Mail Merge’ script, which he went on to develop as a very successful YAMM add-on before refocusing on the Mergo Mail Merge. Even further back when Google Apps Script was officially launched in 2009 this included a [introductory video with a mail merge example](https://www.youtube.com/watch?v=7ux-IexZFec).

A well as Google official channels the ability to automate your Gmail inbox has regularly caught the attention of the wider tech press. In 2013, [Computerworld highlighted Jonathan Kim’s ‘Gmail No Response’ script](https://www.computerworld.com/article/2701635/this-script-makes-sure-you-never-forget-an-email-you-have-to-follow-up-on.html) which goes through your inbox and finds recent emails where you were the last respondent. Jonathan’s blog post is no longer available but the [Gmail No Response’ script is on GitHub](https://github.com/hijonathan/google-scripts/blob/master/gmail-no-response.js) where it has been forked 100 times.

One of those forks is a variation by Christopher Gee published in [Find emails with no reply automatically in Gmail](https://www.rixxo.com/find-emails-with-no-reply-automatically-in-gmail/) which:

> runs through the emails in your inbox and checks your outgoing messages for a question mark. Once it finds these emails it checks to see if they are in a date range and then sees if you have had a response. If you have not had a reply to your email containing a “?” then it adds the label “No Response”. You can then quickly see all of the threads for which you are awaiting a reply.

If you are interested in more Gmail script solutions then I highly recommend you have a look at content shared by Amit Agarwal. This doesn’t just include Apps Script solutions but also a number of [Gmail tips and tricks](https://www.labnol.org/topic/gmail). As many of these feature the way you can search your Gmail inbox they can also be used with [`GmailApp.search()`](https://developers.google.com/apps-script/reference/gmail/gmail-app#search(String)) or if using the Gmail Advanced Service [`Gmail.Users.Messages.list`](https://developers.google.com/gmail/api/reference/rest/v1/users.messages/list). A nice example of where a Gmail user tip can be used in Apps Script is Amit’s post which includes how to [Search Emails by Specific Time in Gmail](https://www.labnol.org/internet/gmail-search-tips/29206/#search-emails-by-specific-time-in-gmail).

The list of examples could go on (and I’ve not even mentioned Stonian’s recent post [Keep your Gmail inbox size in check with google app scripts](https://stonian.tk/auto-gmail-cleanup-with-scripts-google-com-c86e5ad353d5) :). Do you have a favourite ‘tip, trick or script’ for Gmail and Google Apps Script?

Sources:

- *[Hands-on with Google Apps Script: Accessing Google Sheets, Maps, and Gmail in 4 lines of code!](https://codelabs.developers.google.com/codelabs/apps-script-intro#0)*
- *[Create a mail merge with Gmail &amp; Google Sheets](https://developers.google.com/apps-script/samples/automations/mail-merge)*
- *[4 ways to do Mail Merge using Google Apps Script](https://gsuite-developers.googleblog.com/2011/10/4-ways-to-do-mail-merge-using-google.html)*
- *[Google Apps Script: Introduction \[Video\]](https://www.youtube.com/watch?v=7ux-IexZFec)*
- *[This script makes sure you never forget an email you have to follow up on \[Computerworld\]](https://www.computerworld.com/article/2701635/this-script-makes-sure-you-never-forget-an-email-you-have-to-follow-up-on.html)*
- *[Find Emails With No Reply Automatically In Gmail | Rixxo | B2B Magento Marketing Specialists](https://www.rixxo.com/find-emails-with-no-reply-automatically-in-gmail/)*
- *[How to Search Emails in Gmail by Specific Time](https://www.labnol.org/internet/gmail-search-tips/29206/)*
- *[Keep your Gmail inbox size in check with google app scripts](https://stonian.tk/auto-gmail-cleanup-with-scripts-google-com-c86e5ad353d5)*