how use client-side html to server-side in Gmail add-on apps-script?

42 views Asked by At

when use client-side html to server-side then not show out put of client side html in Gmail add-on sidebar. Gmail add-on side bar show message that "Content not available for this message".

Gmail Add-on

this code is .gs

function onGmailSidebarOpen() {
  return HtmlService.createHtmlOutputFromFile('client_sidebar');
}

function doSomething() {
  try {
    Logger.log('doSomething() was called!');
    // Add your logic here
  } catch (error) {
    Logger.log('Error in doSomething(): ' + error);
    throw new Error('An error occurred while processing.');
  }
}

this blow code is client-side html

"client_sidebar.html"

<!DOCTYPE html>
<html>
<head>
  <base target="_top">
  
</head>
<style>
 
    body {
      font-family: Arial, sans-serif;
      margin: 20px;
    }
    
    h2 {
      margin-top: 0;
    }
   
  </style>
<body>
<h2> Gmail Detail </h2>
  <button> openDialog </button>
  <script>
    google.script.run.withSuccessHandler(onSuccess).withFailureHandler(onFailure).doSomething();

    function onSuccess() {
      console.log('Function executed successfully!');
    }

    function onFailure(error) {
      console.error('An error occurred:', error);
    }
  </script>
</body>
</html> 

I want show and button with css. but not show out put of these codes. when use this code show message on gmail sidebar "Content not available for this message".

thanks for your suggestion.

1

There are 1 answers

0
TheMaster On

I don't think returning ui with HtmlService is possible. GmailAddons have to return Ui elements created with CardService.