I have a web app which take some inputs and I need to write those inputs in a sheet and then send an email with those inputs.
My code is below, I removed some lines in the code because they are not relevant. Assume pnArray and qArray are two arrays with values (strings and numbers).
The problem statement is how to create a HTML table in the loop below and then send that table by email.
function submitInfo() {
var table = "<table><tbody><tr><td>Part Number</td><td>Packs</td></tr>";
var pnArray = ["string1","string2"];
var qArray = [1,2];
for(var i =0;i<pnArray.length;i++){
var pn = pnArray[i];
var q = qArray[i];
table += Utilities.formatString('<tr><td>%s</td>', pn);
table += Utilities.formatString('<td>%s</td></tr>', q);
}
table+="</tbody></table>";
GmailApp.sendEmail("[email protected]", "test", null, {htmlBody:table});
}