Skip to content
Advertisement

Pass Google Apps Script (GAS) – Charts Service chart to HTML Template to create within GAS to create Modeless Dialog Box

User: Tanaike kindly answered my question here:

Pass Google Apps Script (GAS) – Charts Service chart to HTML Template within GAS

However, I realized that I’d like to also edit my template and use a modeless dialog box to do some formatting prior to sending an email; I find it helpful to preview my work in the modeless dialog box.

While I can now send charts within an email, which is great, after trying and not succeeding, I realized I’m not aware if it’s possible to pass the chart image to a modeless dialog box. I continue to receive broken links.

The chart data is all boilerplate code from https://developers.google.com/apps-script/reference/charts

////////////////////////////////////// GAS code .gs ↓↓↓

JavaScript

////////////////////////////////////// HTML ↓↓↓

JavaScript

Advertisement

Answer

Unfortunately, the value of message doesn’t include the image data. So, in order to achieve your goal, how about modifying it as follows.

Modified script:

Google Apps Script side:

JavaScript

HTML side:

JavaScript
  • In this modification, when a dialog is opened, cid:sampleImage is replaced with the data of imageUrl. And, when an email is sent, cid:sampleImage is used. Namely, the image data is replaced for the dialog and the email.
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement