Embedded Google form in email?

微笑、不失礼 提交于 2019-11-27 18:50:35

问题


I'm embedded Google form in email by Google apps script but the form doesn't submit correctly from Outlook and from iPhone. It works from Google Mail client only?

Is there's away to solve this problem of submission from iphone or outlook?

Thanks Amany


回答1:


To use forms embedded in emails, the email client needs to support html forms. Outlook has its own forms, but does not support the html form element (reference). I haven't found a reference for iPhone, but it's likely that it also limits the html support. (I use the gmail client on my phone... it supports forms.)

If you're using the code from Send form by email and track responses in spreadsheet, then you can extend your script to provide a doGet function for users that don't have HTML Forms support in their email clients.

The previous gist has been updated with these changes. (Actually, the gist already had the doGet() function.)

Code.gs

Extend this code by adding a doGet() function, which will host the exact same form that you're embedding in the email.

/**
 * GET handler to provide alternate online form.
 */
function doGet() {
  // Build survey body
  var template = HtmlService.createTemplateFromFile('emailTemplate');
  template.scriptUrl = ScriptApp.getService().getUrl();
  template.serialNumber = getGUID();  // Generate serial number for this response
  var app = template.evaluate();
  return app;
}

Make the following modification to the sendSurvey() function:

var plainText = 'Please complete this survey online at: ' + scriptUrl;
html += '<p>Alternatively, you may <A href="' + scriptUrl + '"> complete this survey online.</A>';

// Send email form
GmailApp.sendEmail(recipient, subject, plainText, {htmlBody:html} );

Now, recipients without HTML support in their email client will have a plain text message with an address they can paste into a browser, while HTML clients without <FORM> support will have a clickable link to the online form.



来源:https://stackoverflow.com/questions/18851051/embedded-google-form-in-email

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!