Skip to content
Advertisement

Google scripts Bounced emails

The following stackoverflow link (Google Scripts – Grab email address from bounced message and parse information) has given very good information on how to tackle the Bounces using script from Amit Agarwal at (https://www.labnol.org/internet/gmail-bounced-email-report/29209/).

My question is on whether the code can be called programmatically? I have tried putting each of the code snippets into functions and call them, in vain.

JavaScript

I have also tried copying the code into my project, and the lines with “const” are showing syntax errors and could not save the code in the sheet.

After the inputs from https://stackoverflow.com/users/1595451/rubén made the code as below which will collect the date, subject and email of the bounced email and store data in the google sheet. Posting this to help others.

JavaScript

On the first run, you need to provide the permission to access the corresponding Gmail email box. All the best in coding.

Advertisement

Answer

One way to call the code “programatically” is this:

JavaScript

Anyway, the code in the question is fine but it requires to use the new Google Apps Script runtime, V8, because it uses

  1. Arrow functions
  2. Template strings
  3. let and const
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement