I need your help.
Context
I 'm generating a draft email with variable depending on Gsheet cells I have used this good youtube video as a starter https://www.youtube.com/watch?v=h2z13YE3kJg
The Code
I have create this code :
// filename code.gs
function emailbrouillon() {
// variable pour la creation du fichier HTML
var emailTemp = HtmlService.createTemplateFromFile("EMAIL");
//variable pour appeller le "sheet" du fichier actif
var ws = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("emailSI");
// la variable d'appel pour l'objet dans l'onglet final
var wsSettings = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("emailSI");
// Sauver les lignes dans les variables Emails addresse et l'objet généré en colonne B
var nom = wsSettings.getRange("$B$1").getValue();
var sujet = wsSettings.getRange("$B$2").getValue();
var destinataire = wsSettings.getRange("$B$3").getValue();
var cc = wsSettings.getRange("$B$4").getValue();
var from = wsSettings.getRange("$B$6").getValue();
var corps32 = wsSettings.getRange("$B$41").getValue();
emailTemp.nom = nom;
emailTemp.sujet = sujet;
emailTemp.destinataire = destinataire;
emailTemp.cc = cc;
emailTemp.from = from;
// Graphique
emailTemp.corps32 = corps32;
var htmlMessage = emailTemp.evaluate().getContent();
GmailApp.createDraft
(
mail,
sujet,
"Votre messagerie ne support pas HTML",
//envoyé le message créé htmlbody et le htmlmessage créé.
{name: nom, htmlBody: htmlMessage,cc: cc, from: from}
);
}
Where corps32 is the publish chart url https://docs.google.com/spreadsheets/d/e/sheetID/pubchart?oid=9911774433&format=image>> But this way I have the url generated by the html file below not the picture itself
//filename EMAIL.html
<p style="margin: 0cm 0cm 6pt; line-height: 110%; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-family: verdana, geneva, sans-serif;">Introduction</span></p>
<p style="margin: 0cm 0cm 6pt; line-height: 110%; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-family: verdana, geneva, sans-serif;"><br /><<<?= corps32 ?>>></span></p>
how can i do to get it and include it in my html file ?
If the way to get the chart image is not good
Can you provide me a sheet exemple for the same ?
Thank you
