Error In Sending Email In Google Appmaker
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(
Solution 1:
Unfortunately, you cannot pass whatever you want as a parameter to your server function. Communication to the server has some limitations:
...most types are legal, but not Date, Function, or DOM element...
...objects that create circular references will also fail...
App Maker's records definitely violate those restrictions.
There are different strategies to handle this limitation, one of them is passing record's key as function's parameter.
// Client scriptfunctionsendEmail(widget) {
var item = widget.datasource.item;
google.script.run
...
.sendEmails(item._key);
}
// Server scriptfunctionsendEmails(itemKey) {
var item = app.models.MyModel.getRecord(itemKey);
...
}
Solution 2:
Looks like your Mail Body needs to be converted in HTML Body,
Here's the sample
functionsendEmails(item){
var to = item.OwnerEmail;
var subject = 'Please Review';
var body = 'hello<br/>my name is Muhammad Alif bin Azali';
var template = HtmlService.createTemplate(body);
var htmlBody = template.evaluate().getContent();
MailApp.sendEmail({
to: to,
subject: subject,
htmlBody: htmlBody ,
noReply: true
});
}
Post a Comment for "Error In Sending Email In Google Appmaker"