{"id":427,"date":"2025-03-27T01:23:57","date_gmt":"2025-03-26T22:23:57","guid":{"rendered":"https:\/\/denielkruusman24.thkit.ee\/wp\/eng\/?page_id=427"},"modified":"2025-03-27T01:23:57","modified_gmt":"2025-03-26T22:23:57","slug":"googleappsscript-sendmail-from-form-examples","status":"publish","type":"page","link":"https:\/\/denielkruusman24.thkit.ee\/wp\/eng\/?page_id=427","title":{"rendered":"GoogleAppsScript: SendMail from form examples"},"content":{"rendered":"\n<p>is made a beautiful form with its own fields (Important! one of the fields is an email).<\/p>\n\n\n\n<p>&#8211;<\/p>\n\n\n\n<p>GoogleTable saves the form entries<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" data-src=\"https:\/\/denielkruusman24.thkit.ee\/wp\/wp-content\/uploads\/2025\/03\/image-4.png\" alt=\"\" class=\"wp-image-466 lazyload\" style=\"width:1194px;height:auto\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" data-src=\"https:\/\/denielkruusman24.thkit.ee\/wp\/wp-content\/uploads\/2025\/03\/image-5.png\" alt=\"\" class=\"wp-image-467 lazyload\" style=\"width:1185px;height:auto\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" \/><\/figure>\n\n\n\n<p>Add Google Apps Script<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\nfunction sendEmailToClient() {\n  \/\/ \u0422\u0435\u043a\u0443\u0449\u0430\u044f \u0413\u0443\u0433\u043b \u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e:\n  var ss = SpreadsheetApp.getActiveSpreadsheet();\n\n  \/\/ \u041b\u0438\u0441\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441 \u0438\u043c\u0435\u043d\u0435\u043c &quot;\u041e\u0442\u0432\u0435\u0442\u044b \u043d\u0430 \u0444\u043e\u0440\u043c\u0443 (1)&quot;, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u044e\u0442\u0441\u044f \u043e\u0442\u0432\u0435\u0442\u044b \u0438\u0437 \u0444\u043e\u0440\u043c\u044b, \u0437\u0430\u043f\u0438\u0441\u0430\u043d \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e:\n  var listAnswers = ss.getSheetByName(&quot;Vastused 1&quot;);\n\n  \/\/ \u041f\u043e\u043b\u0443\u0447\u0435\u043d email \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0438\u0437 \u044f\u0447\u0435\u0439\u043a\u0438 \u0441 \u0430\u0434\u0440\u0435\u0441\u043e\u043c: \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0441\u0442\u0440\u043e\u043a\u0430, 10 \u0440\u044f\u0434, - \u0438 \u0437\u0430\u043f\u0438\u0441\u0430\u043d \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e:\n  var clientEmail = listAnswers.getRange(listAnswers.getLastRow(), 10).getValue();\n\n  \/\/ valik\n  var valik = listAnswers.getRange(listAnswers.getLastRow(), 6).getValue();\n\n  \/\/ \u0422\u0435\u043b\u043e \u043f\u0438\u0441\u044c\u043c\u0430, \u043e\u0442\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0432 html-\u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0435, \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e:\n  var Valik1 =\n    &#039;Tere! &lt;br\/&gt; Hello, we have received your &lt;strong&gt;response to the questionnaire&lt;\/strong&gt;&lt;br\/&gt;&#039; +\n    &#039;We look forward to continuing to communicate with you!&lt;br\/&gt;&#039; +\n    &#039;&lt;br\/&gt;&lt;br\/&gt;&#039; + &#039;&lt;a href=&quot;https:\/\/www.tthk.ee\/&quot;&gt;Rohkem info &lt;\/a&gt;&lt;br\/&gt;&#039; +\n    &#039;Sincerely, &lt;br\/&gt; Survey Creator&#039;;\n\n  var Valik2 =\n    &#039;Tere! &lt;br\/&gt; Hello, we have received your &lt;strong&gt;response to the questionnaire&lt;\/strong&gt;&lt;br\/&gt;&#039; +\n    &#039;We apologize for any inconvenience caused.!&lt;br\/&gt;&#039; +\n    &#039;&lt;br\/&gt;&lt;br\/&gt;&#039; + &#039;&lt;a href=&quot;https:\/\/www.tthk.ee\/&quot;&gt;Rohkem info &lt;\/a&gt;&lt;br\/&gt;&#039; +\n    &#039;Sincerely, &lt;br\/&gt; Survey Creator&#039;;\n\n  var Valiamata =\n    &#039;Tere! &lt;br\/&gt; We didnt get any response from you to our &lt;strong&gt;survey&lt;\/strong&gt;&lt;br\/&gt;&#039; +\n    &#039;Sincerely, &lt;br\/&gt; Survey Creator&#039;;\n\n  var body;\n\n  \/\/ \u0423\u0441\u043b\u043e\u0432\u0438\u044f\n  if (valik == &quot;Why not (Yes)&quot;) {\n    body = Valik1;\n  } else if (valik == &quot;I dont have time (No)&quot;) {\n    body = Valik2;\n  } else {\n    body = Valiamata;\n  }\n\n  MailApp.sendEmail(clientEmail, &quot;Vormi vastus&quot;, &#039;&#039;, {htmlBody: body});\n}\n\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>is made a beautiful form with its own fields (Important! one of the fields is an email). &#8211; GoogleTable saves the form entries Add Google Apps Script<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"saved_in_kubio":false,"footnotes":""},"class_list":["post-427","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>GoogleAppsScript: SendMail from form examples - Deniel Kruusman Portfolio<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/denielkruusman24.thkit.ee\/wp\/eng\/?page_id=427\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"GoogleAppsScript: SendMail from form examples - Deniel Kruusman Portfolio\" \/>\n<meta property=\"og:description\" content=\"is made a beautiful form with its own fields (Important! one of the fields is an email). &#8211; GoogleTable saves the form entries Add Google Apps Script\" \/>\n<meta property=\"og:url\" content=\"https:\/\/denielkruusman24.thkit.ee\/wp\/eng\/?page_id=427\" \/>\n<meta property=\"og:site_name\" content=\"Deniel Kruusman Portfolio\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/denielkruusman24.thkit.ee\\\/wp\\\/eng\\\/?page_id=427\",\"url\":\"https:\\\/\\\/denielkruusman24.thkit.ee\\\/wp\\\/eng\\\/?page_id=427\",\"name\":\"GoogleAppsScript: SendMail from form examples - Deniel Kruusman Portfolio\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/denielkruusman24.thkit.ee\\\/wp\\\/eng\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/denielkruusman24.thkit.ee\\\/wp\\\/eng\\\/?page_id=427#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/denielkruusman24.thkit.ee\\\/wp\\\/eng\\\/?page_id=427#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/denielkruusman24.thkit.ee\\\/wp\\\/wp-content\\\/uploads\\\/2025\\\/03\\\/image-4.png\",\"datePublished\":\"2025-03-26T22:23:57+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/denielkruusman24.thkit.ee\\\/wp\\\/eng\\\/?page_id=427#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/denielkruusman24.thkit.ee\\\/wp\\\/eng\\\/?page_id=427\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/denielkruusman24.thkit.ee\\\/wp\\\/eng\\\/?page_id=427#primaryimage\",\"url\":\"https:\\\/\\\/denielkruusman24.thkit.ee\\\/wp\\\/wp-content\\\/uploads\\\/2025\\\/03\\\/image-4.png\",\"contentUrl\":\"https:\\\/\\\/denielkruusman24.thkit.ee\\\/wp\\\/wp-content\\\/uploads\\\/2025\\\/03\\\/image-4.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/denielkruusman24.thkit.ee\\\/wp\\\/eng\\\/?page_id=427#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\",\"item\":\"https:\\\/\\\/denielkruusman24.thkit.ee\\\/wp\\\/eng\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"GoogleAppsScript: SendMail from form examples\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/denielkruusman24.thkit.ee\\\/wp\\\/eng\\\/#website\",\"url\":\"https:\\\/\\\/denielkruusman24.thkit.ee\\\/wp\\\/eng\\\/\",\"name\":\"Deniel Kruusman Portfolio\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/denielkruusman24.thkit.ee\\\/wp\\\/eng\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"GoogleAppsScript: SendMail from form examples - Deniel Kruusman Portfolio","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/denielkruusman24.thkit.ee\/wp\/eng\/?page_id=427","og_locale":"en_US","og_type":"article","og_title":"GoogleAppsScript: SendMail from form examples - Deniel Kruusman Portfolio","og_description":"is made a beautiful form with its own fields (Important! one of the fields is an email). &#8211; GoogleTable saves the form entries Add Google Apps Script","og_url":"https:\/\/denielkruusman24.thkit.ee\/wp\/eng\/?page_id=427","og_site_name":"Deniel Kruusman Portfolio","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/denielkruusman24.thkit.ee\/wp\/eng\/?page_id=427","url":"https:\/\/denielkruusman24.thkit.ee\/wp\/eng\/?page_id=427","name":"GoogleAppsScript: SendMail from form examples - Deniel Kruusman Portfolio","isPartOf":{"@id":"https:\/\/denielkruusman24.thkit.ee\/wp\/eng\/#website"},"primaryImageOfPage":{"@id":"https:\/\/denielkruusman24.thkit.ee\/wp\/eng\/?page_id=427#primaryimage"},"image":{"@id":"https:\/\/denielkruusman24.thkit.ee\/wp\/eng\/?page_id=427#primaryimage"},"thumbnailUrl":"https:\/\/denielkruusman24.thkit.ee\/wp\/wp-content\/uploads\/2025\/03\/image-4.png","datePublished":"2025-03-26T22:23:57+00:00","breadcrumb":{"@id":"https:\/\/denielkruusman24.thkit.ee\/wp\/eng\/?page_id=427#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/denielkruusman24.thkit.ee\/wp\/eng\/?page_id=427"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/denielkruusman24.thkit.ee\/wp\/eng\/?page_id=427#primaryimage","url":"https:\/\/denielkruusman24.thkit.ee\/wp\/wp-content\/uploads\/2025\/03\/image-4.png","contentUrl":"https:\/\/denielkruusman24.thkit.ee\/wp\/wp-content\/uploads\/2025\/03\/image-4.png"},{"@type":"BreadcrumbList","@id":"https:\/\/denielkruusman24.thkit.ee\/wp\/eng\/?page_id=427#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430","item":"https:\/\/denielkruusman24.thkit.ee\/wp\/eng\/"},{"@type":"ListItem","position":2,"name":"GoogleAppsScript: SendMail from form examples"}]},{"@type":"WebSite","@id":"https:\/\/denielkruusman24.thkit.ee\/wp\/eng\/#website","url":"https:\/\/denielkruusman24.thkit.ee\/wp\/eng\/","name":"Deniel Kruusman Portfolio","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/denielkruusman24.thkit.ee\/wp\/eng\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"kubio_ai_page_context":{"short_desc":"","purpose":"general"},"_links":{"self":[{"href":"https:\/\/denielkruusman24.thkit.ee\/wp\/eng\/index.php?rest_route=\/wp\/v2\/pages\/427","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/denielkruusman24.thkit.ee\/wp\/eng\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/denielkruusman24.thkit.ee\/wp\/eng\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/denielkruusman24.thkit.ee\/wp\/eng\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/denielkruusman24.thkit.ee\/wp\/eng\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=427"}],"version-history":[{"count":1,"href":"https:\/\/denielkruusman24.thkit.ee\/wp\/eng\/index.php?rest_route=\/wp\/v2\/pages\/427\/revisions"}],"predecessor-version":[{"id":428,"href":"https:\/\/denielkruusman24.thkit.ee\/wp\/eng\/index.php?rest_route=\/wp\/v2\/pages\/427\/revisions\/428"}],"wp:attachment":[{"href":"https:\/\/denielkruusman24.thkit.ee\/wp\/eng\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=427"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}