Hi all,
I would like to send an email which contains a link / button in the HTML email body. Once the recipient clicked on the link / button, I would like to run a server-side function on Google Apps Script.
Somehow, I can't get this to work (the logs in the function
runFuncServer never show up). Can you please share if you see any issue with the below code? Or if I should be addressing this problem through another approach?
Many thanks for the help
Anas
Here is my Code.gs:
function launchTest() {
var htmlStringService = HtmlService.createHtmlOutputFromFile("EmailBody");
GmailApp.
sendEmail(
"random...@gmail.com",
"Title",
'Body not used', {
htmlBody:
htmlStringService.
getContent()});
}
function runFuncServer() {
console.info('Server function was called correctly!');
}
Here is EmailBody.html:
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<script>
function runFuncClient(){
google.script.run.runFuncServer();
}
</script>
<body>
This is a simple email. Please click <button onclick='runFuncClient()'>here</button>
</body>
</html>