This site has moved.
Note: This library reuses the code in the tutorial Simple Mail Merge available in the Google Apps Script documentation.
It lets you replaces markers in a template string with values in a row.
Library key: MD6VoUXdwcQpfeNDJUagDfFjzL90iNPPq
createTextFromTemplate(String template, Array rowValues, Array headers)
Replaces markers in a template string with values in a row.
Arguments:
Return Values:
Type
String
Description
the copy of the template
function myFunction(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var data = ss.getSheets()[0].getDataRange().getValues();
var template = ss.getSheets()[1].getRange(2, 1).getValue();
for(var i = 1; i < data.length; i++){
var html = MailMerge.createTextFromTemplate(template, data[i], data[0]);
Logger.log('html created from row '+ (i+1) +': '+html);
}
}