I want to send an email notification whenever the user clicks on a button. The button will call sendEmail(widget) function and invoke a client script as follow:
function sendEmail(widget){
var item = widget.datasource.item;
google.script.run
.withFailureHandler(function(error) {
console.text = error.message;
})
.withSuccessHandler(function(result) {
console.text = 'succeed';
})
.sendEmails(item);
}
then it will pass the datasource on item and call sendEmails(item) function from a server script as follows:
function sendEmails(item){
var to = item.OwnerEmail;
var subject = 'Please Review';
var body = 'hello<br/>my name is Muhammad Alif bin Azali';
MailApp.sendEmail({
to: to,
subject: subject,
htmlBody: body,
noReply: true
});
}
but when I click the button I got following error instead. Any help?

Logger.log(item.OwnerEmail);aftervar to = item.OwnerEmail;line - Darpan Sanghavi