Reputation: 77
I'm trying to build a sidebar in my google sheet and assign to it a script to send an emails. The problem is the title and close button displays correctly but the content of the sidebar is not displaying and it gives an error : "n-sf2kk5ynt6qhvo6tzp2uamld3a63ce7qvtsloby-0lu-script.googleusercontent.com took too long to respond."
This is the code I used:
function onOpen() {
SpreadsheetApp.getUi() // Or DocumentApp or SlidesApp or FormApp.
.createMenu('Control Panel')
.addItem('Email', 'showEmail')
.addToUi();
}
function showEmail() {
var html = HtmlService.createHtmlOutputFromFile('Page')
.setTitle('Email Panel')
.setWidth(300);
SpreadsheetApp.getUi() // Or DocumentApp or SlidesApp or FormApp.
.showSidebar(html);
}
2.Page.html
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<div>Hello World!</div>
<input type="button" value="Close" onclick="google.script.host.close()" />
</body>
</html>
Upvotes: 0
Views: 623
Reputation: 77
The issue is solved now, weirdly it was a problem with my router so resetting the router solved it thanks for all the help.
Upvotes: 1
Reputation: 64100
Here's a simple sidebar script to send and email
function sendemaildialog() {
var html='<html><body>';
html+='<form><input type="text" name="email" placeholder="Email Address" /><br/><input type="text" name="subject" placeholder="Subject"/>';
html+='<br/><textarea rows="4" cols="30" name="message"></textarea><br/><input type="button" value="Send" onclick="google.script.run.sendEmail(this.parentNode);"/></form>';
html+='</body></html>';
SpreadsheetApp.getUi().showSidebar(HtmlService.createHtmlOutput(html));
}
function sendEmail(obj) {
GmailApp.sendEmail(obj.email, obj.subject, obj.message);
}
Upvotes: 0