0
votes

First, I'm not positive whether this is an issue with Google Apps Script or the iOS mail app. I've spent a while trying to find anything about the iOS mail app converting embedded html form methods and can't find a single thing.

I am embedding a simple HTML form and sending it via email with Google Apps Script. I'm using post for the form's method and I have a doPost function set up in the script I'm posting back to.

This has been working great for a few months now but I received word from one of my users yesterday that for some reason they were getting a strange error when they tried to submit the form. The user has an iPhone and uses the included Mail app for her email.

I've set up a very simple test script that contains one input and a submit that posts to a simple script to test out the issue. After testing on an iPad, I've found that for whatever reason when I submit with the iOS Mail app, my script returns an error that a doGet function isn't found. I also tested the form using the Gmail iOS app and it calls my doPost method without any issues.

Just to see what happens, I added a doGet function to my script as well and it runs just fine.

Why is the iOS mail app converting my form method from post to get?

Test script that creates the email:

 function sendEmail(){
  var emailhtml = '<body><form name="iOSemailformtest" action="'+ScriptApp.getService().getUrl()+'" method="post">';
  emailhtml += '<input type="radio" name="approval" value="approve">Approve Request<br />';
  emailhtml += '<input type="radio" name="approval" value="deny">Deny Request<br />';
  emailhtml += '<input type="submit" value="Submit Decision">';
  emailhtml += '</form></body>';
  MailApp.sendEmail("[email protected]", "iOS Email Form Test", "HTML Not Supported?", {htmlBody: emailhtml});
}
1

1 Answers

0
votes

If form submission using post isn't reliable, I'd switch to just triggering a function, and not even use a form. Collect the data from the form by getting values out of the fields one by one, or use this.parent to get an object of all the elements in the forms parent element.

var myFieldValue = document.getElementById('idOfInputField').value;

or

<form onsubmit="myFunctionToTrigger(this)">

or

<input onchange="myFunctionToTrigger(this.parent)">