I have received some code from a helpful retool developer to output emails but I can’t get it to work. See below.
//Create a variable called rows that retrieves the table1 data
var rows = table1.data;
function runQuery(){
//Use a for loop to increment through the rows entries one by one,
//printing the name and email.
for(let i=0; i< rows.length; i++){
var ist = i;
var tlname = rows[i]?.ToLastName;
var tfname = rows[i]?.ToFirstName;
var emailad = rows[i]?.ToEmailAddress;
var emailcont = rows[i]?.EmailContent;
var flname = rows[i]?.FromLastName;
var ffname = rows[i]?.FromFirstName;
localStorage.setValue ('mist', ist);
localStorage.setValue ('mtlname', tlname);
localStorage.setValue ('mtfname', tfname);
localStorage.setValue ('memailad', emailad);
localStorage.setValue ('memailcont', emailcont);
localStorage.setValue ('mflname', flname);
localStorage.setValue ('mffname', ffname);
console.log("i is: = ", ist);
console.log("To Last Name is: ", tlname);
console.log("To First Name is: ", tfname);
console.log("Email Address is: ", emailad);
console.log("Email Content is: ", emailcont);
console.log("From Last Name is: ", flname);
console.log("From First Name is: ", ffname);
EmailForm2.trigger();
}
}
//Execute the function runQuery()
runQuery();
The table for the data is below.
This generates 4 mails with each Run but they are all for the last row of the table.
Any thoughts?
Mike
