2

I work in a small team at my office and every day we have to send out 5-10 emails to clients with a small formatted table of data. Currently we do this manually but I would like to write a script that generates the templates as drafts for us and we can simply verify and send out. It would be embedded in a spreadsheet stored on a Team Drive of which we are all owners.

There is a slightly manually step involved so I believe it's best to keep the script as "runable" from an individual's alias, however afterwards we sort of split the responsibility of sending the emails in half in the team based on which clients are involved. Therefore, ideally the drafts should be created in an inbox of which we are all delegated members by some administrator in our company.

Thus, my question is: can I get my GAS to createDraft() into the delegated inbox instead of the personal draft folder of the individual who runs the script? The individual running it will change each week. And, the time of day we will need to run it will vary ~20 minutes each day so I can't set it on a trigger.

Currently my script is a container-bound script on the spreadshet, which this line of code for the draft:

GmailApp.createDraft(recip, subject, null,{cc: cc, htmlBody: fullBody});

It creates a draft in the personal inbox of the "clicker" of the script. The Gmail API is enabled by all users of the spreadsheet/script.

Thanks!

Dylan Gimpelj
  • 306
  • 3
  • 11
  • to clarify, this delegated inbox is already created and we are all delegated members already. This is unchangeable policy of my department as far as I'm aware. – Dylan Gimpelj Sep 17 '18 at 16:47
  • 1
    Try using the Gmail REST API, as an advanced service which can be enabled. You'll need to access the Google Cloud Project for the script, which can be especially fun for scripts in Team Drives. – tehhowch Sep 17 '18 at 17:13
  • Thanks, the problem is I am a simply cog worker so I do not have domain-wide privileges, I cannot use Users.settings.delegates or anything. Is there no way for delegates to send drafts to the delegate inbox? Or run the script as the email address of the ''delegated'' inbox instead of my personal address? – Dylan Gimpelj Sep 17 '18 at 18:53
  • 1
    You aren't trying to create or modify delegate settings, so that endpoint isn't needed. The rest API allows you to specify the email address that you are working with. As far as dealing with messages / drafts, it's a bit tougher as you are then dealing with MIME message representations and not a class object. I'm not currently able to test anything here so a comment is all you'll get from me – tehhowch Sep 17 '18 at 19:08

0 Answers0