I wanna set up a google script that will, with a press of a button, send one email to each user on the list. I have already set up the button, but I need help with merging all the values for one user in one mail instead of sending multiple emails with one value to the same person.
For example:
I basically need Rose to get one email which will have these items listed one below another:
pens
printer
sketchpad
ink and toners
and so on.
This is the script I have so far and there's a HTML body of the email as well:
function myFunction() {
var name = 0;
var email = 1;
var objects = 2
var emailTemp = HtmlService.createTemplateFromFile("body")
var ws = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet2");
var data = ws.getRange("A2:D" + ws.getLastRow()).getValues();
data.forEach(function(row){
emailTemp.fn = row[name];
emailTemp.site = row[objects];
var htmlMessage = emailTemp.evaluate().getContent();
GmailApp.sendEmail(row[email], "No objects ordered", "Blabla",{htmlBody: htmlMessage})
});
}