Search code examples
google-apps-scriptgmailgmail-api

GmailApp getAliases doesn't include the account's main email address


GmailApp getAliases is useful to get the list of aliases / imported accounts, it works.

But the returned list does not include the account's main email address.

How to get the account's main email address from GmailApp? (without hardcoding it in a Google Apps script)

enter image description here


Solution

  • In this case, I would like to propose the following script.

    const emailAddress = Session.getActiveUser().getEmail();
    
    Reference: