2
votes

I have been working with google apps & script for a while now and have since been unable to figure this out. Is there a decent way to pop-up a draft email with "to", "cc", "subject", "message", "attachments" (attachments can just be drive folder) within google sheets?

I am able to send emails with the above, just would like the added benefit of previewing and editing my canned responses etc. before sent.

Thanks in advance for the help!

2

2 Answers

0
votes

You cannot display an actual GMail page; Google Apps Script is executed on Google Server and has very limited control over what happens in the browser. It can display messages and accept input, but not open arbitrary webpages as pop-ups.

It's easy to give the user a preview of a message and the option of sending or canceling it: Browser.msgBox would do.

But there isn't a convenient way of offering to edit a text via Browser class: the inputBox method doesn't have an option of pre-filling the box, and in any case its textbox is a single line, not suitable for editing an email.

I see two options:

  1. (Hard) Write a web app using HttpService that will interact with the user.
  2. (Easy but not as nice): show the preview using Browser.msgBox; if the user presses Cancel, put the content of the email in the spreadsheet somewhere, where the user will edit it and then trigger "send" again, e.g., via a button or a custom menu option.
0
votes

you could open a custom dialogue, which can be of any dimension, and can have the functions of a regular webpage. Don't know if this helps, but our team wrote this code for attaching files to script using GAS.