0

I'm looking to write a google apps script which runs under Gmail, triggered by an incoming email and interacts with a third party web app based on the contents of the email.

I've done something similar using VBA with MS Access, using a browser widget to interact with a web app but would like to develop this in google apps script as a native Gmail app, however, I just cannot see how to get started. There does not appear to be GAS class/methods for browsers only the regular Google apps (docs, sheets, cal.. but not chrome). I'm obviously missing something but what?

Shubham Jain
  • 16,610
  • 15
  • 78
  • 125
paudax
  • 11
  • 1

1 Answers1

0

In Google Apps Script, you can use the Gmail Service and UrlFetchApp.

It looks like you might already have a plan for the emails/triggers, but just in case, here are a couple resources that may help:

Trigger Google Apps Script by email

How to trigger a Google Apps Script once an email get in the inbox?

If I am correct, you are referring to the WebBrowser object in VB. To the best of my knowledge, there is no equivalent to this in Google Apps Script. However, there is UrlFetchApp which you can used to make GET/POST requests. Depending on how much automation you are doing, this may not sound equivalent to the browser object where you can see what you are doing in VB, but you can use Google Chrome's Developer Tools to catch the outgoing requests and emulate those same requests using UrlFetchApp. For example, for a simple request, you can do:

 // The code below logs the HTML code of the Google home page.
 var response = UrlFetchApp.fetch("http://www.google.com/");
 Logger.log(response.getContentText());

For a more complex request where you need to be logged into a website, you will want to use cookies. Here is an example of that:

Cookie handling in Google Apps Script - How to send cookies in header?

Note that requests issued using Google Apps Script are sent from Google's servers/IP.

If you were looking for a popup browser session where you can see what you are doing and automate the browser (non-headless), one idea can be to use Python with the Splinter module.

Augustine C
  • 794
  • 6
  • 20