我正在尝试使用应用程序脚本在电子邮件中嵌入一个表单。我在Send form by email and track responses in spreadsheet的底部遇到了一个有趣的想法
在开发ui和管理响应方面,一个简单的方法是通过使用Google基础设施创建一个表单,通过电子邮件发送表单,然后点击Show原件。 然后,您可以使用嵌入的代码,并使用您的纸条发送您的邮件,响应将自动记录在与表单关联的电子表格中。
基于此,我创建了一个文件“t1.html”,如屏幕截图中所示

我有:
var html = HtmlService
.createTemplateFromFile('t1')
.evaluate();
MailApp.sendEmail('me@gmail.com', "Activity Form: ",html);当我运行它时,我得到以下信息:
Malformed HTML content: <html><body style=3D"font-family: Roboto,Helvetica,Arial,sans-serif; margin 我做错什么了?
编辑:
我得到了同样的错误,但在文件的末尾。主体和html标签在底部是红色的,在顶部是绿色的。

edit2:

我想,我修正了-但是同样的错误,标签底部仍然是红色的?
编辑3-整个表单:
<html><body style=3D"font-family: Roboto,Helvetica,Arial,sans-serif; margin=
: 0; padding: 0; height: 100%; width: 100%;"><table border=3D"0" cellpaddin=
g=3D"0" cellspacing=3D"0" style=3D"background-color:rgb(61, 143, 45);" widt=
h=3D"100%" role=3D"presentation"><tbody><tr height=3D"64px"><td style=3D"pa=
dding-left: 24px"><img alt=3D"Google Forms" height=3D"26px" style=3D"displa=
y: inline-block; margin: 0; vertical-align: middle;" width=3D"143px" src=3D=
"https://www.gstatic.com/docs/forms/google_forms_logo_lockup_white_2x.png">=
</td></tr></tbody></table><div style=3D"padding: 24px; background-color:rgb=
(205, 231, 199)"><table align=3D"center" border=3D"0" cellpadding=3D"0" cel=
lspacing=3D"0" style=3D"max-width: 672px; min-width: 154px;" width=3D"100%"=
role=3D"presentation"><tbody><tr><td style=3D"font-size: 13px; line-height=
: 18px; color: #424242; font-weight: 700">Having trouble viewing or submitt=
ing this form?</td></tr><tr height=3D"8px"><td></td></tr><tr><td><table bor=
der=3D"0" cellpadding=3D"0" cellspacing=3D"0" width=3D"100%"><tbody><tr><td=
><a href=3D"https://docs.google.com/forms/d/e/1FAIpQLSfj58g-87jOhRZfaFjK97s=
XZJs91v6ArzwBiwf060x0IDH-SQ/viewform?c=3D0&w=3D1&usp=3Dmail_form_li=
nk" style=3D"border-radius: 3px; box-sizing: border-box; display: inline-bl=
ock; font-size: 13px; font-weight: 700; height: 40px; line-height: 40px; pa=
dding: 0 24px; text-align: center; text-decoration: none; text-transform: u=
ppercase; vertical-align: middle; color: #fff; background-color: rgb(61, 14=
3, 45);" target=3D"_blank" rel=3D"noopener">FILL OUT IN GOOGLE FORMS</a></t=
d></tr></tbody></table></td></tr><tr height=3D"24px"><td></td></tr></tbody>=
</table><div align=3D"center" style=3D"background-color: #fff; border-botto=
m: 1px solid #e0e0e0; margin: 0 auto; max-width: 624px; min-width: 154px; p=
adding: 0 24px;"><table align=3D"center" cellpadding=3D"0" cellspacing=3D"0=
" style=3D"background-color: #fff;" width=3D"100%" role=3D"presentation"><t=
body><tr height=3D"24px"><td></td></tr><tr><td><span style=3D"display: tabl=
e-cell; vertical-align: top; font-size: 13px; line-height: 18px; color: #42=
4242;">I've invited you to fill out a form:</span></td></tr><tr height=
=3D"20px"><td></tr><tr style=3D"font-size: 20px; line-height: 24px;"><td><s=
pan style=3D"display: table-cell;"><a href=3D"https://docs.google.com/forms=
/d/e/1FAIpQLSfj58g-87jOhRZfaFjK97sXZJs91v6ArzwBiwf060x0IDH-SQ/viewform?c=3D=
0&w=3D1&usp=3Dmail_form_link" style=3D"color: rgb(61, 143, 45); tex=
t-decoration: none; vertical-align: middle; font-weight: 500">Document Info=
rmation</a><div itemprop=3D"action" itemscope itemtype=3D"http://schema.org=
/ViewAction"><meta itemprop=3D"url" content=3D"https://docs.google.com/form=
s/d/e/1FAIpQLSfj58g-87jOhRZfaFjK97sXZJs91v6ArzwBiwf060x0IDH-SQ/viewform?c=
=3D0&w=3D1&usp=3Dmail_goto_form"><meta itemprop=3D"name" content=3D=
"Fill out form"></div></span></td></tr><tr height=3D"16px"></tr><tr><td><sp=
an style=3D"display: table-cell; vertical-align: top; font-size: 13px; line=
-height: 18px; color: #424242;">This info will be used on our documents</sp=
an></td></tr><tr height=3D"24px"></tr><tr><td><div class=3D"ss-form" style=
=3D""><form action=3D"https://docs.google.com/forms/u/0/d/e/1FAIpQLSfj58g-8=
7jOhRZfaFjK97sXZJs91v6ArzwBiwf060x0IDH-SQ/formResponse" method=3D"POST" id=
=3D"ss-form" target=3D"_self" onsubmit=3D"" style=3D""><ol role=3D"list" cl=
ass=3D"ss-question-list" style=3D"padding-left: 0;list-style-type:none;">
<div class=3D"ss-form-question errorbox-good" role=3D"listitem" style=3D"">
<div dir=3D"auto" class=3D"ss-item ss-item-required ss-text" style=3D"margi=
n:12px 0;"><div class=3D"ss-form-entry" style=3D"margin-bottom:1.5em;vertic=
al-align:middle;margin-left:0;margin-top:0;max-width:100%;">
<label class=3D"ss-q-item-label" for=3D"entry_2005620554" style=3D""><div c=
lass=3D"ss-q-title" style=3D"display:block;font-weight:bold;margin-top:.83e=
m;margin-bottom:.83em;">Owner's First Name
<label for=3D"itemView.getDomIdToLabel()" aria-label=3D"(Required field)" s=
tyle=3D""></label>
<span class=3D"ss-required-asterisk" aria-hidden=3D"true" style=3D"color:#c=
43b1d;">*</span></div>
<div class=3D"ss-q-help ss-secondary-text" dir=3D"auto" style=3D"display:bl=
ock;margin:.1em 0 .25em 0;color:#666;"></div></label>
<input type=3D"text" name=3D"entry.2005620554" value=3D"" class=3D"ss-q-sho=
rt" id=3D"entry_2005620554" dir=3D"auto" aria-label=3D"Owner's First Na=
me " aria-required=3D"true" title=3D"" style=3D"">
</div></div></div> <div class=3D"ss-form-question errorbox-good" role=3D"li=
stitem" style=3D"">
<div dir=3D"auto" class=3D"ss-item ss-item-required ss-text" style=3D"margi=
n:12px 0;"><div class=3D"ss-form-entry" style=3D"margin-bottom:1.5em;vertic=
al-align:middle;margin-left:0;margin-top:0;max-width:100%;">
<label class=3D"ss-q-item-label" for=3D"entry_2126206062" style=3D""><div c=
lass=3D"ss-q-title" style=3D"display:block;font-weight:bold;margin-top:.83e=
m;margin-bottom:.83em;">Owner's Last Name
<label for=3D"itemView.getDomIdToLabel()" aria-label=3D"(Required field)" s=
tyle=3D""></label>
<span class=3D"ss-required-asterisk" aria-hidden=3D"true" style=3D"color:#c=
43b1d;">*</span></div>
<div class=3D"ss-q-help ss-secondary-text" dir=3D"auto" style=3D"display:bl=
ock;margin:.1em 0 .25em 0;color:#666;"></div></label>
<input type=3D"text" name=3D"entry.2126206062" value=3D"" class=3D"ss-q-sho=
rt" id=3D"entry_2126206062" dir=3D"auto" aria-label=3D"Owner's Last Nam=
e " aria-required=3D"true" title=3D"" style=3D"">
</div></div></div> <div class=3D"ss-form-question errorbox-good" role=3D"li=
stitem" style=3D"">
<div dir=3D"auto" class=3D"ss-item ss-item-required ss-text" style=3D"margi=
n:12px 0;"><div class=3D"ss-form-entry" style=3D"margin-bottom:1.5em;vertic=
al-align:middle;margin-left:0;margin-top:0;max-width:100%;">
<label class=3D"ss-q-item-label" for=3D"entry_1045781291" style=3D""><div c=
lass=3D"ss-q-title" style=3D"display:block;font-weight:bold;margin-top:.83e=
m;margin-bottom:.83em;">Owner's Street Address
<label for=3D"itemView.getDomIdToLabel()" aria-label=3D"(Required field)" s=
tyle=3D""></label>
<span class=3D"ss-required-asterisk" aria-hidden=3D"true" style=3D"color:#c=
43b1d;">*</span></div>
<div class=3D"ss-q-help ss-secondary-text" dir=3D"auto" style=3D"display:bl=
ock;margin:.1em 0 .25em 0;color:#666;"></div></label>
<input type=3D"text" name=3D"entry.1045781291" value=3D"" class=3D"ss-q-sho=
rt" id=3D"entry_1045781291" dir=3D"auto" aria-label=3D"Owner's Street A=
ddress " aria-required=3D"true" title=3D"" style=3D"">
</div></div></div> <div class=3D"ss-form-question errorbox-good" role=3D"li=
stitem" style=3D"">
<div dir=3D"auto" class=3D"ss-item ss-item-required ss-text" style=3D"margi=
n:12px 0;"><div class=3D"ss-form-entry" style=3D"margin-bottom:1.5em;vertic=
al-align:middle;margin-left:0;margin-top:0;max-width:100%;">
<label class=3D"ss-q-item-label" for=3D"entry_2093621735" style=3D""><div c=
lass=3D"ss-q-title" style=3D"display:block;font-weight:bold;margin-top:.83e=
m;margin-bottom:.83em;">Owner's Town/City
<label for=3D"itemView.getDomIdToLabel()" aria-label=3D"(Required field)" s=
tyle=3D""></label>
<span class=3D"ss-required-asterisk" aria-hidden=3D"true" style=3D"color:#c=
43b1d;">*</span></div>
<div class=3D"ss-q-help ss-secondary-text" dir=3D"auto" style=3D"display:bl=
ock;margin:.1em 0 .25em 0;color:#666;"></div></label>
<input type=3D"text" name=3D"entry.2093621735" value=3D"" class=3D"ss-q-sho=
rt" id=3D"entry_2093621735" dir=3D"auto" aria-label=3D"Owner's Town/Cit=
y " aria-required=3D"true" title=3D"" style=3D"">
</div></div></div> <div class=3D"ss-form-question errorbox-good" role=3D"li=
stitem" style=3D"">
<div dir=3D"auto" class=3D"ss-item ss-item-required ss-text" style=3D"margi=
n:12px 0;"><div class=3D"ss-form-entry" style=3D"margin-bottom:1.5em;vertic=
al-align:middle;margin-left:0;margin-top:0;max-width:100%;">
<label class=3D"ss-q-item-label" for=3D"entry_1159980352" style=3D""><div c=
lass=3D"ss-q-title" style=3D"display:block;font-weight:bold;margin-top:.83e=
m;margin-bottom:.83em;">Owner's State
<label for=3D"itemView.getDomIdToLabel()" aria-label=3D"(Required field)" s=
tyle=3D""></label>
<span class=3D"ss-required-asterisk" aria-hidden=3D"true" style=3D"color:#c=
43b1d;">*</span></div>
<div class=3D"ss-q-help ss-secondary-text" dir=3D"auto" style=3D"display:bl=
ock;margin:.1em 0 .25em 0;color:#666;"></div></label>
<input type=3D"text" name=3D"entry.1159980352" value=3D"" class=3D"ss-q-sho=
rt" id=3D"entry_1159980352" dir=3D"auto" aria-label=3D"Owner's State "=
aria-required=3D"true" title=3D"" style=3D"">
</div></div></div> <div class=3D"ss-form-question errorbox-good" role=3D"li=
stitem" style=3D"">
<div dir=3D"auto" class=3D"ss-item ss-item-required ss-text" style=3D"margi=
n:12px 0;"><div class=3D"ss-form-entry" style=3D"margin-bottom:1.5em;vertic=
al-align:middle;margin-left:0;margin-top:0;max-width:100%;">
<label class=3D"ss-q-item-label" for=3D"entry_97849368" style=3D""><div cla=
ss=3D"ss-q-title" style=3D"display:block;font-weight:bold;margin-top:.83em;=
margin-bottom:.83em;">Owner's Zip=20
<label for=3D"itemView.getDomIdToLabel()" aria-label=3D"(Required field)" s=
tyle=3D""></label>
<span class=3D"ss-required-asterisk" aria-hidden=3D"true" style=3D"color:#c=
43b1d;">*</span></div>
<div class=3D"ss-q-help ss-secondary-text" dir=3D"auto" style=3D"display:bl=
ock;margin:.1em 0 .25em 0;color:#666;"></div></label>
<input type=3D"number" name=3D"entry.97849368" value=3D"" class=3D"ss-q-sho=
rt" id=3D"entry_97849368" dir=3D"auto" aria-label=3D"Owner's Zip Must=
be a number" aria-required=3D"true" title=3D"Must be a number" style=3D"">
</div></div></div> <div class=3D"ss-form-question errorbox-good" role=3D"li=
stitem" style=3D"">
<div dir=3D"auto" class=3D"ss-item ss-paragraph-text" style=3D"margin:12px=
0;"><div class=3D"ss-form-entry" style=3D"margin-bottom:1.5em;vertical-ali=
gn:middle;margin-left:0;margin-top:0;max-width:100%;">
<label class=3D"ss-q-item-label" for=3D"entry_1065046570" style=3D""><div c=
lass=3D"ss-q-title" style=3D"display:block;font-weight:bold;margin-top:.83e=
m;margin-bottom:.83em;">Property Legal Description
</div>
<div class=3D"ss-q-help ss-secondary-text" dir=3D"auto" style=3D"display:bl=
ock;margin:.1em 0 .25em 0;color:#666;"></div></label>
<textarea name=3D"entry.1065046570" rows=3D"8" cols=3D"0" class=3D"ss-q-lon=
g" id=3D"entry_1065046570" dir=3D"auto" aria-label=3D"Property Legal Descri=
ption " style=3D"resize:vertical;width:70%;"></textarea>
</div></div></div> <div class=3D"ss-form-question errorbox-good" role=3D"li=
stitem" style=3D"">
<div dir=3D"auto" class=3D"ss-item ss-text" style=3D"margin:12px 0;"><div =
class=3D"ss-form-entry" style=3D"margin-bottom:1.5em;vertical-align:middle;=
margin-left:0;margin-top:0;max-width:100%;">
<label class=3D"ss-q-item-label" for=3D"entry_205266861" style=3D""><div cl=
ass=3D"ss-q-title" style=3D"display:block;font-weight:bold;margin-top:.83em=
;margin-bottom:.83em;">Property Account Number
</div>
<div class=3D"ss-q-help ss-secondary-text" dir=3D"auto" style=3D"display:bl=
ock;margin:.1em 0 .25em 0;color:#666;"></div></label>
<input type=3D"text" name=3D"entry.205266861" value=3D"" class=3D"ss-q-shor=
t" id=3D"entry_205266861" dir=3D"auto" aria-label=3D"Property Account Numbe=
r " title=3D"" style=3D"">
</div></div></div> <div class=3D"ss-form-question errorbox-good" role=3D"li=
stitem" style=3D"">
<div dir=3D"auto" class=3D"ss-item ss-text" style=3D"margin:12px 0;"><div =
class=3D"ss-form-entry" style=3D"margin-bottom:1.5em;vertical-align:middle;=
margin-left:0;margin-top:0;max-width:100%;">
<label class=3D"ss-q-item-label" for=3D"entry_1714605862" style=3D""><div c=
lass=3D"ss-q-title" style=3D"display:block;font-weight:bold;margin-top:.83e=
m;margin-bottom:.83em;">Property Address
</div>
<div class=3D"ss-q-help ss-secondary-text" dir=3D"auto" style=3D"display:bl=
ock;margin:.1em 0 .25em 0;color:#666;"></div></label>
<input type=3D"text" name=3D"entry.1714605862" value=3D"" class=3D"ss-q-sho=
rt" id=3D"entry_1714605862" dir=3D"auto" aria-label=3D"Property Address " =
title=3D"" style=3D"">
</div></div></div>
<input type=3D"hidden" name=3D"draftResponse" value=3D"[null,null,"883=
0551375159526782"]
" style=3D"">
<input type=3D"hidden" name=3D"pageHistory" value=3D"0" style=3D"">
<input type=3D"hidden" name=3D"usp" value=3D"mail_form_submit" style=3D"">
<input type=3D"hidden" name=3D"fbzx" value=3D"8830551375159526782" style=3D=
"">
<div class=3D"ss-item ss-navigate" style=3D"margin:12px 0;"><table id=3D"na=
vigation-table" style=3D""><tbody><tr><td class=3D"ss-form-entry goog-inlin=
e-block" id=3D"navigation-buttons" dir=3D"ltr" style=3D"margin-bottom:1.5em=
;vertical-align:middle;margin-left:0;margin-top:0;max-width:100%;position:r=
elative;display:inline-block;">
<input type=3D"submit" name=3D"submit" value=3D"Submit" id=3D"ss-submit" cl=
ass=3D"jfk-button jfk-button-action " style=3D"">
<div class=3D"ss-password-warning ss-secondary-text" style=3D"color:#666;">=
Never submit passwords through Google Forms.</div></td>
</tr></tbody></table></div></ol></form></div>
<div class=3D"ss-footer" style=3D""><div class=3D"ss-attribution" style=3D"=
"></div>
<div class=3D"ss-legal" style=3D""><div class=3D"disclaimer-separator" styl=
e=3D""></div>
<div class=3D"disclaimer" dir=3D"ltr" style=3D""><div class=3D"powered-by-l=
ogo" style=3D"margin-top:2em;"><span class=3D"powered-by-text" style=3D"">P=
owered by</span>
<a href=3D"https://www.google.com/forms/about/?utm_source=3Dproduct&utm=
_medium=3Dforms_logo&utm_campaign=3Dforms" style=3D""><div class=3D"ss-=
logo-container" style=3D""><img src=3D"https://ssl.gstatic.com/docs/forms/f=
orms_logo_2_small_dark_2x.png" height=3D"21px" width=3D"108px" alt=3D"Googl=
e Forms" style=3D""></div></a></div>
<div class=3D"ss-terms" style=3D"color:#777;font-size:11px;margin-top:1.5em=
;"><span class=3D"disclaimer-msg" style=3D"">This content is neither create=
d nor endorsed by Google.</span>
<br>
<a href=3D"https://docs.google.com/forms/u/0/d/e/1FAIpQLSfj58g-87jOhRZfaFjK=
97sXZJs91v6ArzwBiwf060x0IDH-SQ/reportabuse?source=3Dhttps://docs.google.com=
/forms/d/e/1FAIpQLSfj58g-87jOhRZfaFjK97sXZJs91v6ArzwBiwf060x0IDH-SQ/viewfor=
m?sid%3D2b7fc9792dfd5e0b%26c%3D0%26w%3D1%26token%3DI_Y1xl4BAAA.glSNAM2muxH-=
ZfYW-H1nuw.UAuDr1pX_XDohsgv8ZiNdg" style=3D"">Report Abuse</a>
-
<a href=3D"http://www.google.com/accounts/TOS" style=3D"">Terms of Service<=
/a>
-
<a href=3D"http://www.google.com/google-d-s/terms.html" style=3D"">Addition=
al Terms</a></div></div></div></div>
</td></tr><tr height=3D"24px"></tr></tbody></table></div><table align=3D"ce=
nter" cellpadding=3D"0" cellspacing=3D"0" style=3D"max-width: 672px; min-wi=
dth: 154px;" width=3D"100%" role=3D"presentation"><tbody><tr height=3D"24px=
"><td></td></tr><tr><td><a href=3D"https://docs.google.com/forms?usp=3Dmail=
_form_link" style=3D"color: #616161; font-size: 13px;">Create your own Goog=
le Form</a></td></tr></tbody></table></div></body></html>发布于 2017-09-28 20:11:03
为了完成这个问题,上面的模板是正确的,并链接到一个工作表。我把我的代码改为:
function buildFollowUpForm() {
var html = doGet();
MailApp.sendEmail({
to: 'me@gmail.com',
subject: 'hi',
htmlBody: html
});
}
function doGet() {
var template = HtmlService.createTemplateFromFile('t1');
var app = template.evaluate().getContent();
return app;
}https://stackoverflow.com/questions/46459953
复制相似问题