I am trying to change one word from a template I have in a spreadsheet, for the value that the user inputs through the inputbox. When I run my script it doesnt change the word, any ideas??
function sendEmails() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var time = Browser.inputBox("Enter TIME");
var address = "albdominguez25@gmail.com";
ss.setActiveSheet(ss.getSheetByName("Templates"));
var emailTemplate = ss.getRange("B1").getValue();
//here I am trying to replace the word "TIME" on my template to the value entered on the inputBox
emailTemplate.replace("TIME",time);
var emailSubject = "Tutorial: Simple Mail Merge";
MailApp.sendEmail(address, emailSubject, emailTemplate);
}
Albert,
I believe the source of your replace is not assigning the result of the emailTemplate.replace to a variable.
I also did a little bit to the SpreadsheetApp call. Depends on what you are after of course.
Jim
function sendEmails() {
var emailTemplate = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Templates").getRange("B1").getValue();
var time = Browser.inputBox("Enter TIME");
var address = "jcampbell@neonova.net";
emailTemplate = emailTemplate.replace("TIME",time);
var emailSubject = "Tutorial: Simple Mail Merge";
MailApp.sendEmail(address, emailSubject, emailTemplate);
}