If you’re a Gmail user, you might have noticed that the auto-population feature that suggests email addresses when you start typing in the “To” field isn’t working for you. This can be a frustrating issue, especially if you have to send a lot of emails to the same group of people. Fortunately, with Google Apps Script, you can quickly and easily fix this problem.

First, let’s take a closer look at what might be causing this issue. The auto-population feature is powered by Gmail’s contact group feature, which is a way to group together multiple email addresses for easier access. If you’re not seeing suggestions for email addresses, it’s possible that you don’t have any contact groups set up in your Gmail account.

To fix this issue using Google Apps Script, you’ll need to start by creating a new contact group in Gmail. You can do this by following these steps:

  1. Open Gmail and click on the “Gmail” drop-down menu in the top left corner.
  2. From the menu, select “Contacts.”
  3. In the left-hand pane, click on “Labels.”
  4. Click on the “Create label” button at the top of the pane.
  5. Give your new label a name that you’ll recognize as your new contact group, such as “Work Contacts.”
  6. Click “Save” to create the new label.

Once you’ve created your new contact group, you’ll need to add email addresses to it. You can do this manually by clicking on the new contact group label in the left-hand pane, and then clicking on the “Add a contact” button at the top of the screen. Alternatively, you can use Google Apps Script to add contacts to the group automatically.

To use Google Apps Script to add contacts to your new group automatically, you’ll need to write a script that searches your emails for specific phrases or keywords, and then adds the email addresses of the senders to your contact group. Here’s an example script that you can modify to fit your needs:

function addContactsToGroup() {
    var thread = GmailApp.search("subject:work"); //Replace "work" with your desired keyword
    var contacts = [];

    for (var i = 0; i < thread.length; i++) {
        var message = thread[i].getMessages()[0];
        var email = message.getFrom();

        if (contacts.indexOf(email) == -1) {

    var contactGroup = ContactsApp.getContactGroup("Work Contacts");
    for (var j = 0; j < contacts.length; j++) {
        var newContact = ContactsApp.createContact(contacts[j]);

In this script, you’ll need to replace “work” in the search function with your desired keyword or phrase. The script will search for emails with that keyword in the subject line, and then add the email addresses of the senders to your “Work Contacts” group.

To run this script automatically, you can set up a time-driven trigger in the “Triggers” menu of the Google Apps Script editor. This will ensure that the script runs at regular intervals, such as every hour or every day.