0

I'm trying to embed a form in an email using apps script. I've come across an interesting idea at the bottom of Send form by email and track responses in spreadsheet:

A simple way to do this with little work with regard to the developing a ui and managing the responses, is to create a from using the Google Apps infrastructure, sending yourself the form by email and clicking on show original.

You can then take the embedded code and use in your scrip to send your mails, the response will be recorded in the spreadsheet associated with the form automatically.

Based on this I have created a file 't1.html' as in the screenshot

I have:

var html = HtmlService
  .createTemplateFromFile('t1')
  .evaluate();

MailApp.sendEmail('me@gmail.com', "Activity Form: ",html);

When I run it I get the following:

Malformed HTML content: <html><body style=3D"font-family: Roboto,Helvetica,Arial,sans-serif; margin 

What am I doing wrong ?

edit:

I'm getting the same error but at the end of the file. The body and html tags are red at the bottom but green at the top.

enter image description here

edit2:

enter image description here

I think, I fixed that - but same error, tags at bottom are still red?

edit 3 -- entire form:

  <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&amp;w=3D1&amp;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&#39;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&amp;w=3D1&amp;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&amp;w=3D1&amp;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&#39;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&#39;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&#39;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&#39;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&#39;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&#39;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&#39;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&#39;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&#39;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&#39;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&#39;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&#39;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,&quot;883=
  0551375159526782&quot;]
  " 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&amp;utm=
  _medium=3Dforms_logo&amp;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>
Rubén
  • 34,714
  • 9
  • 70
  • 166
user1592380
  • 34,265
  • 92
  • 284
  • 515
  • 1
    Remove all 3D on all of your attributes (style="" role="" ..) this is wrong style=3D"..." this is good style="..." –  Sep 28 '17 at 02:25
  • That definitely helped but I'm getting an error. Please see screenshot – user1592380 Sep 28 '17 at 12:41
  • i didn't see a new picture did you upload it? –  Sep 28 '17 at 12:44
  • First line should be like this –  Sep 28 '17 at 12:49
  • please see edit 2 – user1592380 Sep 28 '17 at 13:07
  • Edit 2 : remove the 2 - at the begin --> - ... - <-- –  Sep 28 '17 at 13:11
  • i guess you send me all the page html and i give your format html i guess if you dont use on the top where are and if you open a tag html and you didn't the doctype can add the missed. –  Sep 28 '17 at 13:14
  • Thanks for taking a look at this. I've sent you an original version before all my changes – user1592380 Sep 28 '17 at 13:33
  • Welcome, you can also copy/paste your html code and try to valid online here https://www.freeformatter.com/html-validator.html –  Sep 28 '17 at 13:35
  • i have to go. come back in 30 min if you didn't solve it ;), regards. –  Sep 28 '17 at 13:37
  • Thanks , I'm looking at the output from freeformatter and there are a lot of errors. Do you have any rules of thumb for debugging this code? – user1592380 Sep 28 '17 at 14:18
  • yes working on element html that need a tag close as (div, ... however if this html is needed for a mail the mail must don't have any javascript inline as
    ...
    –  Sep 28 '17 at 14:35
  • Ok, I'm going to put a bounty on this because I want to see how you do this for embedding in the email body – user1592380 Sep 28 '17 at 15:00
  • can you test :( omg lol. –  Sep 28 '17 at 16:03

2 Answers2

1

Formatted but to mutch parsing error sometime the script add the /n or /r with = before and more 3D ...

<html>
       <body style="font-family: Roboto,Helvetica,Arial,sans-serif; margin: 0; padding: 0; height: 100%; width: 100%;">
          <table border="0" cellpadding="0" cellspacing="0" style="background-color:rgb(61, 143, 45);" width="100%" role="presentation">
             <tbody>
                <tr height="64px">
                   <td style="padding-left: 24px">
                      <img alt="Google Forms" height="26px" style="display: inline-block; margin: 0; vertical-align: middle;" width="143px" src="https://www.gstatic.com/docs/forms/google_forms_logo_lockup_white_2x.png">
                   </td>
                </tr>
             </tbody>
          </table>
          <div style="padding: 24px; background-color:rgb(205, 231, 199)">
             <table align="center" border="0" cellpadding="0" cellspacing="0" style="max-width: 672px; min-width: 154px;" width="100%" role="presentation">
                <tbody>
                   <tr>
                      <td style="font-size: 13px; line-height: 18px; color: #424242; font-weight: 700">
                         Having trouble viewing or submitting this form?
                      </td>
                   </tr>
                   <tr height="8px">
                      <td></td>
                   </tr>
                   <tr>
                      <td>
                         <table border="0" cellpadding="0" cellspacing="0" width="100%">
                            <tbody>
                               <tr>
                                  <td>
                                     <a href="https://docs.google.com/forms/d/e/1FAIpQLSfj58g-87jOhRZfaFjK97sXZJs91v6ArzwBiwf060x0IDH-SQ/viewform?c=0&amp;w=1&amp;usp=mail_form_link" style="border-radius: 3px; box-sizing: border-box; display: inline-block; font-size: 13px; font-weight: 700; height: 40px; line-height: 40px; padding: 0 24px; text-align: center; text-decoration: none; text-transform: uppercase; vertical-align: middle; color: #fff; background-color: rgb(61, 143, 45);" target="_blank" rel="noopener">
                                     FILL OUT IN GOOGLE FORMS
                                     </a>
                                  </td>
                               </tr>
                            </tbody>
                         </table>
                      </td>
                   </tr>
                   <tr height="24px">
                      <td></td>
                   </tr>
                </tbody>
                =
             </table>
             <div align="center" style="background-color: #fff; border-bottom: 1px solid #e0e0e0; margin: 0 auto; max-width: 624px; min-width: 154px; padding: 0 24px;">
                <table align="center" cellpadding="0" cellspacing="0" style="background-color: #fff;" width="100%" role="presentation">
                   <tbody>
                      <tr height="24px">
                         <td></td>
                      </tr>
                      <tr>
                         <td>
                            <span style="display: table-cell; vertical-align: top; font-size: 13px; line-height: 18px; color: #424242;">
                            I&#39;ve invited you to fill out a form:
                            </span>
                         </td>
                      </tr>
                      <tr height="20px">
                         <td></td>
                      </tr>
                      <tr style="font-size: 20px; line-height: 24px;">
                         <td>
                            <span style="display: table-cell;">
                               <a href="https://docs.google.com/forms/d/e/1FAIpQLSfj58g-87jOhRZfaFjK97sXZJs91v6ArzwBiwf060x0IDH-SQ/viewform?c==
                                  0&amp;w=1&amp;usp=mail_form_link" style="color: rgb(61, 143, 45); text-decoration: none; vertical-align: middle; font-weight: 500">
                               Document Information
                               </a>
                               <div itemprop="action" itemscope itemtype="http://schema.org=
                                  /ViewAction">
                                  <meta itemprop="url" content="https://docs.google.com/forms/d/e/1FAIpQLSfj58g-87jOhRZfaFjK97sXZJs91v6ArzwBiwf060x0IDH-SQ/viewform?c=
                                     =0&amp;w=1&amp;usp=mail_goto_form">
                                  <meta itemprop="name" content="Fill out form">
                               </div>
                            </span>
                         </td>
                      </tr>
                      <tr height="16px"></tr>
                      <tr>
                         <td>
                            <span style="display: table-cell; vertical-align: top; font-size: 13px; line-height: 18px; color: #424242;">
                            This info will be used on our documents
                            </span>
                         </td>
                      </tr>
                      <tr height="24px"></tr>
                      <tr>
                         <td>
                            <div class="ss-form" style="">
                               <form action="https://docs.google.com/forms/u/0/d/e/1FAIpQLSfj58g-87jOhRZfaFjK97sXZJs91v6ArzwBiwf060x0IDH-SQ/formResponse" method="POST" id="ss-form" target="_self" onsubmit="" style="">
                                  <ol role="list" class="ss-question-list" style="padding-left: 0;list-style-type:none;">
                                     <div class="ss-form-question errorbox-good" role="listitem" style="">
                                        <div dir="auto" class="ss-item ss-item-required ss-text" style="margin:12px 0;">
                                           <div class="ss-form-entry" style="margin-bottom:1.5em;vertical-align:middle;margin-left:0;margin-top:0;max-width:100%;">
                                              <label class="ss-q-item-label" for="entry_2005620554" style="">
                                                 <div class="ss-q-title" style="display:block;font-weight:bold;margin-top:.83em;margin-bottom:.83em;">
                                                    Owner&#39;s First Name
                                              <label for="itemView.getDomIdToLabel()" aria-label="(Required field)" style=""></label>
                                              <span class="ss-required-asterisk" aria-hidden="true" style="color:#c43b1d;">*</span>
                                              </div>
                                              <div class="ss-q-help ss-secondary-text" dir="auto" style="display:block;margin:.1em 0 .25em 0;color:#666;"></div>
                                              </label>
                                              <input type="text" name="entry.2005620554" value="" class="ss-q-short" id="entry_2005620554" dir="auto" aria-label="Owner&#39;s First Name  " aria-required="true" title="" style="">
                                           </div>
                                        </div>
                                     </div>
                                     <div class="ss-form-question errorbox-good" role="listitem" style="">
                                        <div dir="auto" class="ss-item ss-item-required ss-text" style="margin:12px 0;">
                                           <div class="ss-form-entry" style="margin-bottom:1.5em;vertical-align:middle;margin-left:0;margin-top:0;max-width:100%;">
                                              <label class="ss-q-item-label" for="entry_2126206062" style="">
                                                 <div class="ss-q-title" style="display:block;font-weight:bold;margin-top:.83em;margin-bottom:.83em;">
                                                    Owner&#39;s Last Name
                                              <label for="itemView.getDomIdToLabel()" aria-label="(Required field)" style=""></label>
                                              <span class="ss-required-asterisk" aria-hidden="true" style="color:#c43b1d;">*</span>
                                              </div>
                                              <div class="ss-q-help ss-secondary-text" dir="auto" style="display:block;margin:.1em 0 .25em 0;color:#666;"></div>
                                              </label>
                                              <input type="text" name="entry.2126206062" value="" class="ss-q-short" id="entry_2126206062" dir="auto" aria-label="Owner&#39;s Last Name  " aria-required="true" title="" style="">
                                           </div>
                                        </div>
                                     </div>
                                     <div class="ss-form-question errorbox-good" role="listitem" style="">
                                        <div dir="auto" class="ss-item ss-item-required ss-text" style="margin:12px 0;">
                                           <div class="ss-form-entry" style="margin-bottom:1.5em;vertical-align:middle;margin-left:0;margin-top:0;max-width:100%;">
                                              <label class="ss-q-item-label" for="entry_1045781291" style="">
                                                 <div class="ss-q-title" style="display:block;font-weight:bold;margin-top:.83em;margin-bottom:.83em;">Owner&#39;s Street Address
                                              <label for="itemView.getDomIdToLabel()" aria-label="(Required field)" style=""></label>
                                              <span class="ss-required-asterisk" aria-hidden="true" style="color:#c43b1d;">*</span>
                                              </div>
                                              <div class="ss-q-help ss-secondary-text" dir="auto" style="display:block;margin:.1em 0 .25em 0;color:#666;"></div>
                                              </label>
                                              <input type="text" name="entry.1045781291" value="" class="ss-q-short" id="entry_1045781291" dir="auto" aria-label="Owner&#39;s Street Address  " aria-required="true" title="" style="">
                                           </div>
                                        </div>
                                     </div>
                                     <div class="ss-form-question errorbox-good" role="listitem" style="">
                                        <div dir="auto" class="ss-item ss-item-required ss-text" style="margin:12px 0;">
                                           <div class="ss-form-entry" style="margin-bottom:1.5em;vertical-align:middle;margin-left:0;margin-top:0;max-width:100%;">
                                              <label class="ss-q-item-label" for="entry_2093621735" style="">
                                                 <div class="ss-q-title" style="display:block;font-weight:bold;margin-top:.83em;margin-bottom:.83em;">
                                                    Owner&#39;s Town/City
                                              <label for="itemView.getDomIdToLabel()" aria-label="(Required field)" style=""></label>
                                              <span class="ss-required-asterisk" aria-hidden="true" style="color:#c43b1d;">*</span>
                                              </div>
                                              <div class="ss-q-help ss-secondary-text" dir="auto" style="display:block;margin:.1em 0 .25em 0;color:#666;"></div>
                                              </label>
                                              <input type="text" name="entry.2093621735" value="" class="ss-q-short" id="entry_2093621735" dir="auto" aria-label="Owner&#39;s Town/Cit=
                                                 y  " aria-required="true" title="" style="">
                                           </div>
                                        </div>
                                     </div>
                                     <div class="ss-form-question errorbox-good" role="listitem" style="">
                                        <div dir="auto" class="ss-item ss-item-required ss-text" style="margin:12px 0;">
                                           <div class="ss-form-entry" style="margin-bottom:1.5em;vertical-align:middle;margin-left:0;margin-top:0;max-width:100%;">
                                              <label class="ss-q-item-label" for="entry_1159980352" style="">
                                                 <div class="ss-q-title" style="display:block;font-weight:bold;margin-top:.83em;margin-bottom:.83em;">
                                                    Owner&#39;s State
                                              <label for="itemView.getDomIdToLabel()" aria-label="(Required field)" style=""></label>
                                              <span class="ss-required-asterisk" aria-hidden="true" style="color:#c43b1d;">*</span></div>
                                              <div class="ss-q-help ss-secondary-text" dir="auto" style="display:block;margin:.1em 0 .25em 0;color:#666;"></div>
                                              </label>
                                              <input type="text" name="entry.1159980352" value="" class="ss-q-short" id="entry_1159980352" dir="auto" aria-label="Owner&#39;s State"aria-required="true" title="" style="">
                                           </div>
                                        </div>
                                     </div>
                                     <div class="ss-form-question errorbox-good" role="listitem" style="">
                                        <div dir="auto" class="ss-item ss-item-required ss-text" style="margin:12px 0;">
                                           <div class="ss-form-entry" style="margin-bottom:1.5em;vertical-align:middle;margin-left:0;margin-top:0;max-width:100%;">
                                              <label class="ss-q-item-label" for="entry_97849368" style="">
                                                 <div class="ss-q-title" style="display:block;font-weight:bold;margin-top:.83em;margin-bottom:.83em;">
                                                    Owner&#39;s Zip=20
                                              <label for="itemView.getDomIdToLabel()" aria-label="(Required field)" style=""></label>
                                              <span class="ss-required-asterisk" aria-hidden="true" style="color:#c43b1d;">*</span>
                                              </div>
                                              <div class="ss-q-help ss-secondary-text" dir="auto" style="display:block;margin:.1em 0 .25em 0;color:#666;"></div>
                                              </label>
                                              <input type="number" name="entry.97849368" value="" class="ss-q-short" id="entry_97849368" dir="auto" aria-label="Owner&#39;s Zip   Must=
                                                 be a number" aria-required="true" title="Must be a number" style="">
                                           </div>
                                        </div>
                                     </div>
                                     <div class="ss-form-question errorbox-good" role="listitem" style="">
                                        <div dir="auto" class="ss-item  ss-paragraph-text" style="margin:12px=
                                           0;">
                                           <div class="ss-form-entry" style="margin-bottom:1.5em;vertical-align:middle;margin-left:0;margin-top:0;max-width:100%;">
                                              <label class="ss-q-item-label" for="entry_1065046570" style="">
                                                 <div class="ss-q-title" style="display:block;font-weight:bold;margin-top:.83em;margin-bottom:.83em;">Property Legal Description
                                                 </div>
                                                 <div class="ss-q-help ss-secondary-text" dir="auto" style="display:block;margin:.1em 0 .25em 0;color:#666;"></div>
                                              </label>
                                              <textarea name="entry.1065046570" rows="8" cols="0" class="ss-q-long" id="entry_1065046570" dir="auto" aria-label="Property Legal Description  " style="resize:vertical;width:70%;"></textarea>
                                           </div>
                                        </div>
                                     </div>
                                     <div class="ss-form-question errorbox-good" role="listitem" style="">
                                        <div dir="auto" class="ss-item  ss-text" style="margin:12px 0;">
                                           <div class="ss-form-entry" style="margin-bottom:1.5em;vertical-align:middle;margin-left:0;margin-top:0;max-width:100%;">
                                              <label class="ss-q-item-label" for="entry_205266861" style="">
                                                 <div class="ss-q-title" style="display:block;font-weight:bold;margin-top:.83em;margin-bottom:.83em;">Property Account Number
                                                 </div>
                                                 <div class="ss-q-help ss-secondary-text" dir="auto" style="display:block;margin:.1em 0 .25em 0;color:#666;"></div>
                                              </label>
                                              <input type="text" name="entry.205266861" value="" class="ss-q-short" id="entry_205266861" dir="auto" aria-label="Property Account Number  " title="" style="">
                                           </div>
                                        </div>
                                     </div>
                                     <div class="ss-form-question errorbox-good" role="listitem" style="">
                                        <div dir="auto" class="ss-item  ss-text" style="margin:12px 0;">
                                           <div class="ss-form-entry" style="margin-bottom:1.5em;vertical-align:middle;margin-left:0;margin-top:0;max-width:100%;">
                                              <label class="ss-q-item-label" for="entry_1714605862" style="">
                                                 <div class="ss-q-title" style="display:block;font-weight:bold;margin-top:.83em;margin-bottom:.83em;">Property Address
                                                 </div>
                                                 <div class="ss-q-help ss-secondary-text" dir="auto" style="display:block;margin:.1em 0 .25em 0;color:#666;"></div>
                                              </label>
                                              <input type="text" name="entry.1714605862" value="" class="ss-q-short" id="entry_1714605862" dir="auto" aria-label="Property Address  " title="" style="">
                                           </div>
                                        </div>
                                     </div>
                                     <input type="hidden" name="draftResponse" value="[null,null,&quot;8830551375159526782&quot;]" style="">
                                     <input type="hidden" name="pageHistory" value="0" style="">
                                     <input type="hidden" name="usp" value="mail_form_submit" style="">
                                     <input type="hidden" name="fbzx" value="8830551375159526782" style="">
                                     <div class="ss-item ss-navigate" style="margin:12px 0;">
                                        <table id="navigation-table" style="">
                                           <tbody>
                                              <tr>
                                                 <td class="ss-form-entry goog-inline-block" id="navigation-buttons" dir="ltr" style="margin-bottom:1.5em;vertical-align:middle;margin-left:0;margin-top:0;max-width:100%;position:relative;display:inline-block;">
                                                    <input type="submit" name="submit" value="Submit" id="ss-submit" class="jfk-button jfk-button-action " style="">
                                                    <div class="ss-password-warning ss-secondary-text" style="color:#666;">
                                                    Never submit passwords through Google Forms.
                                                    </div>
                                                 </td>
                                              </tr>
                                           </tbody>
                                        </table>
                                     </div>
                                  </ol>
                               </form>
                            </div>
                            <div class="ss-footer" style="">
                               <div class="ss-attribution" style=""></div>
                               <div class="ss-legal" style="">
                                  <div class="disclaimer-separator" style=""></div>
                                  <div class="disclaimer" dir="ltr" style="">
                                     <div class="powered-by-logo" style="margin-top:2em;">
                                        <span class="powered-by-text" style="">Powered by</span>
                                        <a href="https://www.google.com/forms/about/?utm_source=product&amp;utm_medium=forms_logo&amp;utm_campaign=forms" style="">
                                           <div class="ss-logo-container" style=""><img src="https://ssl.gstatic.com/docs/forms/forms_logo_2_small_dark_2x.png" height="21px" width="108px" alt="Google Forms" style=""></div>
                                        </a>
                                     </div>
                                     <div class="ss-terms" style="color:#777;font-size:11px;margin-top:1.5em;"><span class="disclaimer-msg" style="">
                                     This content is neither created nor endorsed by Google.</span>
                                        <br>
                                        <a href="https://docs.google.com/forms/u/0/d/e/1FAIpQLSfj58g-87jOhRZfaFjK97sXZJs91v6ArzwBiwf060x0IDH-SQ/reportabuse?source=https://docs.google.com/forms/d/e/1FAIpQLSfj58g-87jOhRZfaFjK97sXZJs91v6ArzwBiwf060x0IDH-SQ/viewform?sid%2b7fc9792dfd5e0b%26c%0%26w%1%26token%I_Y1xl4BAAA.glSNAM2muxH-ZfYW-H1nuw.UAuDr1pX_XDohsgv8ZiNdg" style="">Report Abuse</a>
                                        <a href="http://www.google.com/accounts/TOS" style="">Terms of Service</a>
                                        <a href="http://www.google.com/google-d-s/terms.html" style="">Additional Terms</a>
                                     </div>
                                  </div>
                               </div>
                            </div>
                         </td>
                      </tr>
                      <tr height="24px"></tr>
                   </tbody>
                </table>
             </div>
             <table align="center" cellpadding="0" cellspacing="0" style="max-width: 672px; min-width: 154px;" width="100%" role="presentation">
                <tbody>
                   <tr height="24px">
                      <td></td>
                   </tr>
                   <tr>
                      <td><a href="https://docs.google.com/forms?usp=mailform_link" style="color: #616161; font-size: 13px;">Create your own Google Form</a>
                      </td>
                   </tr>
                </tbody>
             </table>
          </div>
       </body>
    </html>
  • I'm getting "TypeError: Cannot find function evaluate in object HtmlOutput." - This refers to var html = HtmlService .createTemplateFromFile('t1') .evaluate(); – user1592380 Sep 28 '17 at 17:01
  • @user61629 did you tryed this issue ? https://stackoverflow.com/questions/20769149/form-and-file-upload-with-htmlservice-and-app-script-not-working i dunno if is out of date but you can check :). –  Sep 28 '17 at 17:19
  • Thanks I will take a look at that later for some debugging help – user1592380 Sep 28 '17 at 17:42
  • I'll ask another question if needed. – user1592380 Sep 28 '17 at 17:42
  • @user61629 Ok so give me the link i can show here, that will alert me ;). –  Sep 28 '17 at 18:12
0

Just to complete this question , the template above is correct and links to a sheet. I changed my code to :

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;
}
user1592380
  • 34,265
  • 92
  • 284
  • 515
  • Congratulation, you got it :). I will try it soon. Thanks for reporting. –  Sep 28 '17 at 20:13