I am sending an html form in body of the mail with a button included and when button is clicked i am saving a reference in google spreadsheet. I was able to get the code and not able to get it worked.please help me in fixing the issue.
//Function to send mail from Google App script
function sendmail(e) {
var subject = 'Test';
var template = HtmlService.createHtmlOutput('<form id = "myForm" >' +
'<label for = "name"> Name: </label>'+
'<input type = "text" id ="name" />'+
'</Form>'+
'<button onclick = "submitdata()">Save</button>' +
'<script>' +
'function submitdata(){'+
'var form = document.getElementByID('+"myform"+');'+
'google.script.run.withFailureHandler(alert).withSuccessHandler(alert).' +
'submitForm(form);'+
'}');
var html = template.getContent();
// email to self
recipient = Session.getActiveUser().getEmail();
var Mailbody= 'Its a test: '
// Send email form
GmailApp.sendEmail(recipient, subject, Mailbody, {htmlBody:html} );
}
//Function to be called when clicked on Save button in Email body
function submitForm(form) {
var ss =SpreadsheetApp.openById('tsgxsbtJRf2zbh_tNQzJoUQ');
var sheet = ss.getSheets()[0];
// Save response to spreadsheet
var rowNum = sheet.getLastRow()+1;
//sheet.getRange(rowNum, 1, 1, row.length).setValues([row]);
sheet.getRange("A"+ rowNum).setValue("today" )
}