How to reference GmailApp in a js file other than Code.gs?
<p>Is it possible to reference <code>GmailApp</code> in a <code>my_custom_js.html</code> file, as opposed to the <code>Code.gs</code> file?  </p>

<p>The following works when used in <code>Code.gs</code>:  </p>

<pre><code>// BEGIN email
// define email recipients
var email_recipient = uploader_email;
// Email subject
var subject = "Form submitted"
// Email body
var body = my_html; 
Logger.log(email_recipient);    
// Send email
GmailApp.sendEmail(email_recipient, subject, body);
// END email
</code></pre>

<p>But it doesn't work when used in a function in <code>my_custom_js.html</code>.</p>

<p><code>Developer Tools</code> > <code>Console</code> shows error:</p>

<pre><code>Uncaught ReferenceError: Logger is not defined
Uncaught ReferenceError: GmailApp is not defined
</code></pre>

<p>The reason I want it to run in the custom script, is that it utilises:</p>

<pre><code>// BEGIN handle form submit
function handleFormSubmit(formObject) {
google.script.run.withSuccessHandler(updateUrl).processForm(formObject);
}
// END handle form submit
</code></pre>

<p>And, if I understand that code correctly, <code>updateUrl</code> is only running after a successful operation - so I'd like to send the email from the <code>updateUrl()</code> function (ie after a successful operation).  </p>

<p>Perhaps I need to use something like a <a href="https://developers.google.com/apps-script/guides/html/templates#scriptlets" rel="nofollow">scriptlet</a> , but for use in js files?</p>

<p><strong>Edit</strong></p>

<p>I'm looking into:</p>

<p><a href="https://developers.google.com/apps-script/guides/html/reference/run" rel="nofollow">https://developers.google.com/apps-script/guides/html/reference/run</a></p>

<p>And will see if I can pass through the values to a function defined in <code>Code.gs</code> using the following in <code>my_custom_js.html</code>:</p>

<pre><code>google.script.run.sendNotificationEmail(arg1,arg2);
</code></pre>

<p><strong>Edit</strong></p>

<p>That last idea worked, but would appreciate any insight on the original question, thanks.  </p>