【问题标题】:Google App Script + Google Sheet + HTML modal dialog input form - Get values and build emailGoogle App Script + Google Sheet + HTML modal dialog input form - 获取值和构建电子邮件
【发布时间】:2020-07-20 22:24:49
【问题描述】:

另一个表格问题。

我的 Google Sheet 上有一张图片,它运行一个脚本,该脚本会调出一个基于 HMTL 的模态对话框:

function HomePageFurtherHelp(){ 

  var ui = SpreadsheetApp.getUi();
  //
  //Call the HTML file and set the width and height
  var html = HtmlService.createHtmlOutputFromFile("Home Page - Further Help")
    .setWidth(1200)
    .setHeight(1400);
  //Display the dialog
  var dialog = ui.showModalDialog(html, " ");
} 

我的 HTML 模态对话框窗口包含一些供用户输入的字段:它基本上是一个联系信息表单,并且有一个“发送”按钮。我在 HTML 中的每个输入字段中添加了“id”参数。该表单只是我添加了 id 的免费使用版本。

我的问题是:如何获取用户输入的数据,然后将其传递给发送按钮并将电子邮件发送到预设的电子邮件地址?我在发送按钮中添加了一个“onclick”参数,我假设我在“onclick”中为电子邮件本身调用了一个函数,但我不知道如何构建它。

<div class="w3-row w3-section">
  <div class="w3-col" style="width:50px"><i class="w3-xxlarge fa fa-user"></i></div>
    <div class="w3-rest">
      <input class="w3-input w3-border" name="first" type="text" placeholder="Your Name" id="userName">
    </div>
</div>

<div class="w3-row w3-section">
  <div class="w3-col" style="width:50px"><i class="w3-xxlarge fa fa-sitemap"></i></div>
    <div class="w3-rest">
      <input class="w3-input w3-border" name="last" type="text" placeholder="Department" id="departmentName">
    </div>
</div>

<div class="w3-row w3-section">
  <div class="w3-col" style="width:50px"><i class="w3-xxlarge fa fa-envelope-o"></i></div>
    <div class="w3-rest">
      <input class="w3-input w3-border" name="email" type="text" placeholder="Email" id="userEmail">
    </div>
</div>

<div class="w3-row w3-section">
  <div class="w3-col" style="width:50px"><i class="w3-xxlarge fa fa-film"></i></div>
    <div class="w3-rest">
      <input class="w3-input w3-border" name="phone" type="text" placeholder="Project?" id="projectName">
    </div>
</div>

<div class="w3-row w3-section">
  <div class="w3-col" style="width:50px"><i class="w3-xxlarge fa fa-pencil"></i></div>
    <div class="w3-rest">
      <input class="w3-input w3-border" name="message" type="text" placeholder="Message" id="userMessage">
    </div>
</div>

<button class="w3-button w3-block w3-section w3-blue w3-ripple w3-padding" onclick="contactSendEmail()">Send</button>

我确实找到了这篇文章:Apps Script: How to Email Google Sheet file to Email Specified in HTML Service Input?,但我有点困惑,把它拆开,我被困在“formObj”上并使用它。

帮助我理解将不胜感激。

谢谢,

【问题讨论】:

    标签: javascript html email google-apps-script onclick


    【解决方案1】:

    我使用 formObj 解决了这个问题,并将我的名称参数称为键 - 这是我缺少的一点。

    这可以关闭等等。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-20
      • 1970-01-01
      • 1970-01-01
      • 2014-01-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-02
      相关资源
      最近更新 更多