Search code examples
google-apps-scriptgmail

How would I find and then send an email to all of the emails in my inbox in Google Apps Script?


I’m trying to make a GMail subscription service with Google Apps Script. I want it to send an email to every single email in my inbox. How would I do this?


Solution

  • function replyToInboxMessages() {
      const threads = GmailApp.getInboxThreads();
      threads.forEach(t => {
        t.getMessages().forEach(m =>{
          GmailApp.sendEmail(m.getFrom(),'Return Email','Quit Sending us Email');
        });
      });
    }