Using a custom script on Google Forms - google-apps-script

I trying to create a custom script to collect the email filled on field (within my Google Form) and send an email when the user clicks on submit button.
Is it possible do it?
note: I don't want to collect the email address of who's filling the form.. I want just collect the email typed on field and send an email.

You won't be able to send the user an email if their email doesn't show up on a Spreadsheet. You're going to have to collect some data in this case, otherwise you won't be able to send them an email.
Use MailApp from gScript to send an email. Pretty simple to do with an onSubmit function.

Related

Google form get email ID when form is loaded for response

I know there is a getRespondentEmail() which retrieves the email id. But if i'm understanding this correctly, it is only when user submits the form then I'll get information through this. Is there a way to get email id when form is loaded for response. Objective is as follows:
1) Get email id when form is loaded for response
2) access a google sheet and filter data based on this email ID
3) provide the filtered list as a drop down for selecting within the form.
Answer:
This is not possible using Google Forms.
Explanation:
In order to get user information before a user has submitted a form, direct access to the browser session must be retrieved by Google's server before form submission. This isn't done.
Until a form has been submitted by the user, therefore giving explicit permission to submit their responses and email address, no information is communicated to Google's servers and as such the email address can not be retrieved before the user submits their answers.
Users are even prompted that their email will be sent with their responses once they submit if the Collect email addresses checkbox is ticked in the Form Settings, as this is personal information and they need to decide if they wish to send this information or not:
Implementing this would be a privacy issue so I can not foresee Google creating this option in the future either.

Force email receipt for Form submission in Google Script

Is there a method in Google Script to force a receipt to be sent via email with a user's form submission? I see there is a way to do it within the Form itself, but there doesn't appear to be a way to do this in the API.

How do I get the active response in a Google Apps Script bound to a form?

I'm writing a script within (bound to) a Google Form. The idea here is to have the respondent enter their email address in the form (that's the only field in the form) and then make a copy of a spreadsheet (based on a template) and email it to them.
The script is triggered by the submission of the form. At the moment I'm wondering what the easiest way would be to grab that email address out of their response. I have gotten as far as figuring out that it's available within FormApp.getActiveForm(), but I can't seem to find a "getActiveResponse()" method. How do I grab that email address they just entered, without scrolling through every response? If there was a getActiveResponse, then I would just grab the contents of Item 1.
The Form submit event has the FormResponse property. This property has the method getRespondentEmail()
If the script is triggered by the submit event, you should be able to fetch the email address from there.

Google Apps Script - Can I send email from another account

I have just implement a simple function to send email automatic when a google form is submitted, with my current account.
When I sign in with other google account and submit this form. I recieve an email with my account (not account is signed). Is there any way to send with the account is signed?
Edit: I think I misunderstood your question...
2 things to know:
When a script sends an email using a triggered function ( a form submit trigger in this case) the mail will always be sent by the account of the creator of the trigger.
As explained below, to get the email address of the user submitting a form you must be part of a google-apps domain.
If you are using your form in a GAFE or business Google Apps account then you can use the getRespondentEmail() method but as mentioned in the documentation this does not work for normal Gmail accounts.

Google Apps Script - Send email as user submitting form data

Using Google Apps for business, I have a form that company users access on a google site. The users completes the form and submits. onSubmit, a script runs, collects the data and puts into a PDF and sends an email to me for review.
Right now when the email is sent, it comes to my inbox as me sending to me. I'd like to have it send as the user submitting the form. Can anyone point me in the direction to send as the user submitting the form.
permissions are set as followed:
The spreadsheet sharing option has anyone at company can find / view.
It's deployed as "execute the apps as:" User accessing the web app. And anyone at the company can access the app.
thoughts?
You can replace the form with an HtmlService or UiApp version that runs as the user, and then the email will come from them.
Assuming your are using Google Forms, I don't believe the function/script being run onSubmit is being run by the user who fills out the form, its being run by the owner of the script (you). As #Corey G stated, you can use HtmlService or UIApp to create a form, but takes much more time to create the form itself.