Retrieve the e-mail address of a Google Form respondent without asking for their e-mail address in the form

brain56 picture brain56 · Oct 17, 2014 · Viewed 65.4k times · Source

The scenario goes:

  1. Via email, a Google Form is sent to a respondent.
  2. Via this sent email, the respondent answers the form and sends their response. This form has no email address field.
  3. I need to retrieve the respondents e-mail address and add it to the spreadsheet where the Google Form responses are recorded.

Via Google Apps script, is it possible to retrieve the respondent's e-mail address in this manner? For specific reasons, I am not allowed to inquire the respondent's e-mail address. Retrieving the e-mail address in this manner also serves as verification so that it is verifiable which of the e-mail addresses I sent the form to have a response.

I am aware that if you have a field which contains the user's e-mail address, this is very do-able. There is even a tutorial specifically about it. However, I haven't seen a guide for the use case described above.

I have attempted using Session.getActiveUser().getEmail(). However, it seems that it only retrieves my own e-mail address (as it considers me, the person viewing the spreadsheet, as the active user).

Answer

Cameron Roberts picture Cameron Roberts · Oct 17, 2014

This can only be done if you are using Google Apps for Business, Google Apps for Education, or Google Apps for Your Domain, and are having users on your domain fill out the form. In that case, you can use getRespondentEmail() to retrieve the submitter's email address.

If your situation doesn't meet the requirement above, Google does not expose the submitter's email address to you and your only option is to prompt them for it on the form.