Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can find script examples in the Apps Script <a href="https://developers.google.com/apps-script/guide">user guide</a> and <a href="https://developers.google.com/apps-script/articles">tutorials</a>. You may also search for related discussions on the <a href="https://groups.google.com/a/googleproductforums.com/forum/#!categories/apps-script">forum</a>. But I don't think there's one that fits you exactly, all code is out there for sure, but not on a single script.</p> <p>It's possible that someone wrote such script and never published it. Since it's somewhat straightforward to do and everyone's usage is different. For instance, how do you plan on marking your emails (the ones you've already read, executed, etc)? It may be nice to use a gmail filter to help you out, putting the "command" emails in a label right away, and the script just remove the label (and possibly set another one). Point is, see how it can differ a lot.</p> <p>Also, I think it's easier if you can keep all functions in the same script project. Possibly just on different files. As calling different scripts is way more complicated.</p> <p>Anyway, he's how I'd start it:</p> <pre class="lang-js prettyprint-override"><code>//set a time-driven trigger to run this function on the desired frequency function monitorEmails() { var label = GmailApp.getUserLabelByName('command'); var doneLabel = GmailApp.getUserLabelByName('executed'); var cmds = label.getThreads(); var max = Math.min(cmds.length,5); for( var i = 0; i &lt; max; ++i ) { var email = cmds[i].getMessages()[0]; var functionName = email.getBody(); //you may need to do extra parsing here, depending on your usage var ret = undefined; try { ret = this[functionName](); } catch(err) { ret = err; } //replying the function return value to the email //this may make sense or not if( ret !== undefined ) email.reply(ret); cmds[i].removeLabel(label).addLabel(doneLabel); } } </code></pre> <p>ps: I have not tested this code</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload