首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >异常:格式错误的HTML内容:</div>错误

异常:格式错误的HTML内容:</div>错误
EN

Stack Overflow用户
提问于 2021-08-26 19:00:40
回答 1查看 202关注 0票数 0

我试图让我的谷歌电子表格发送电子邮件与数据从工作表,也是html格式。每当我试图运行它时,我总是得到以下错误.

错误异常:格式错误的HTML:.评估

评估

myFunction @ waiverClaim.gs:37

我找不到问题。我想问题在于第37行"const htmlForEmail =htmlTemplate.evaluate().getContent()“,但是我不知道哪里出了什么问题,希望这里有人能帮上忙!

下面是正在运行的脚本im

代码语言:javascript
复制
function myFunction() {
  const ss = SpreadsheetApp.getActiveSpreadsheet();
  const ws = ss.getSheetByName("Football");

  const h1 = ws.getRange("A1").getValue();
  const subheader = ws.getRange("A4:F4").getValues();
  const priority = subheader[0][0];
  const player = subheader[0][1];
  const transaction = subheader[0][2];
  const bid = subheader[0][3];
  const years = subheader[0][4]; 
  const dropped = subheader[0][5];

  const lr =  ws.getLastRow();

  const tableRangeValues = ws.getRange(5,1,lr-5,6).getValues();

  const totalLine = ws.getRange(lr,3,1,6).getValues();
  const totalText = totalLine[0][0];
  const totalSum = totalLine[0][1];

const htmlTemplate = HtmlService.createTemplateFromFile("email");

htmlTemplate.h1 = h1;
htmlTemplate.subheader = subheader;
htmlTemplate.priority = priority;
htmlTemplate.player = player;
htmlTemplate.transaction = transaction;
htmlTemplate.bid = bid;
htmlTemplate.years = years;
htmlTemplate.dropped = dropped;
htmlTemplate.totalText = totalText;
htmlTemplate.totalSum = totalSum;
htmlTemplate.tableRangeValues = tableRangeValues;


const htmlForEmail = htmlTemplate.evaluate().getContent();

console.log(htmlForEmail);

GmailApp.sendEmail(
  "me@gmail.com",
  "Waiver Claim Submission",
  "Tom Brady $45 1 year",
  { htmlBody: htmlForEmail }
);

}

以及相应的html:

代码语言:javascript
复制
<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
       </head>
        <body>
             <div>

                <div>
                      <h1><?= h1 ?></h1>
                </div>
                      
                <div> 
                      <div <?= subheader ?></div>
                </div>

              </div> 

        <table>
              <thead> 
                        <tr> 
                            <th><?= priority ?></th>
                            <th><?= player ?></th>
                            <th><?= transaction ?></th>
                            <th><?= bid ?></th>
                            <th><?= years ?></th>
                            <th><?= dropped ?></th>
                        </tr>  
                
               </thead>
       
               <tbody> 
                        <tr> 
                            <td>Col D1</td>
                            <td>Col D2</td>
                            <td>Col D3</td>
                            <td>Col D4</td>
                            <td>Col D5</td>
                            <td>Col D6</td>
                        </tr>  
              </tbody>


                <tfoot>
                        <tr>
                            <td></td>
                            <td></td>
                            <td><?= totalText ?></td>
                            <td><?= totalSum ?></td>
                            <td></td>
                            <td></td>     
                        </tr> 
                </tfoot>
          </table>    
     </body>
</html>

如果我需要提供更多关于情况的信息,我很乐意提供。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-08-26 21:12:00

你错过了><div <?= subheader ?></div>

试着用这个:

代码语言:javascript
复制
<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
       </head>
        <body>
             <div>

                <div>
                      <h1><?= h1 ?></h1>
                </div>
                      
                <div> 
                      <div> <?= subheader ?></div>
                </div>

              </div> 

        <table>
              <thead> 
                        <tr> 
                            <th><?= priority ?></th>
                            <th><?= player ?></th>
                            <th><?= transaction ?></th>
                            <th><?= bid ?></th>
                            <th><?= years ?></th>
                            <th><?= dropped ?></th>
                        </tr>  
                
               </thead>
       
               <tbody> 
                        <tr> 
                            <td>Col D1</td>
                            <td>Col D2</td>
                            <td>Col D3</td>
                            <td>Col D4</td>
                            <td>Col D5</td>
                            <td>Col D6</td>
                        </tr>  
              </tbody>


                <tfoot>
                        <tr>
                            <td></td>
                            <td></td>
                            <td><?= totalText ?></td>
                            <td><?= totalSum ?></td>
                            <td></td>
                            <td></td>     
                        </tr> 
                </tfoot>
          </table>    
     </body>
</html>
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68944050

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档