Google Apps Script - Send email as user submitting form data - google-apps-script

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.

Related

How do you automatically send an email on Google form submit, from the person who submitted the form and not the Google form owner?

After someone (authorised and not myself) submits the Google form I created, which sends an email out to whoever they want, it shows that I (the Google form owner) sent it out myself. Is there a way to remove my email and show the email of the person who submitted the form?
This is the code in Apps Script
function onFormSubmit(e) {
let responses = e.namedValues;
MailApp.sendEmail({
to: responses['Email'],
subject: responses['Subject'],
htmlBody: responses['Message'],
});
}
I believe it might involve using Google Cloud Projects and an API, but I have little/no experience with those.
The problem occurs because your script is using an installable trigger and the Google Apps Script Mail service, as the script is ran using the credentials of the user who create the trigger, in this case you.
In order to send an email using the form submitter email address as sender, one option is to use
Google Workspace accounts from the same domain
Service account
Domain wide delegation of authority
There might be other options to send the emails as the form submitter but all that have thinking about using Google Forms looks to be cumberstone.
A more simple option, still using Google Apps Script, is to create a web app and set it as run as the user accesing the web app.
The more simple solution to avoid showing your email address as the sender is to change the approach: use an alias with a generic name. To do this add an alias to your Gmail account, use GmailApp instead of MailApp and set the script to use the alias instead of your email address.

Google script run after email confirmation

In this case, I don't have a code or screenshots to share because I honestly don't know how to even start it :)
We have a spreadsheet (Google Sheets) which have numerous scripts built into it. They run mainly based on form submission and don't require any further confirmation after a form is submitted. For this new form we wish to implement, we would like to script to run only after a user has confirmed via email. Here's the rundown:
User A (normally from the administration department) will input data into a form.
Once form is submitted, this data will be sent to another user (User B) for confirmation. We would like this process to happen over email, and not directly via Google Sheets prompt.
Once User B confirmed data is good, a script will run to compile the data and perform several actions on it.
No problem to send an email via script but how do we include a confirmation button/link to it and how do we capture this clink to continue the compiling of this data?
Thanks :)
User A Enters data into Form and Presses Submit
FormSubmit Script recovers data and sends email to user B
User B reviews data and Presses a link on the email which sends a request via a web app to complete the transaction at a later time.
You can probably customize the webapp link with query string parameters so that the transaction can be completed without any further interaction but it will probably take a couple of days of programming to complete and test the job.

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.

Email verification using google app script and google forms

I have a google form app which has, among others, an email id field.I want to verify that the email entered by user is the email which belongs to him. Pls note: I DO NOT WANT TO VERIFY THE DOMAIN/SYNTAX OF EMAIL. All emails would be gmail ids, so if that helps, is there a way to send a mail validation link to their gmail accounts and on clicking the link, the entry is made to spreadsheet. Else its cancelled.
Also the link must be valid for limited time only.
Yes this is possible. You can publish a Google script as a web app and add the email address of the recipient as a query parameter to this app. When the user clicks the link, the app is called, the email is verified and the app itself can log an entry into the spreadsheet.

Any way to validate a Google form input?

I want to collect and validate a value (PIN) in a Google Form. The Form has 2 pages, and I'd like the validation to affect form navigation:
If PIN matched with a value in Column N of the response sheet, continue to page 2 of the form
If PIN not matched, Do not continue.
Can this be done with Google Apps Script?
You are not able to create this type of dynamic form using the Google Forms Service, because there is no interaction between the service and scripts during form entry, except upon Form Submission. In the case of a multi-page form, a script has no way to know that a user has completed one page and gone on to another.
You could achieve this using the HtmlService or UiService, by writing your own form.
Not sure you can do this with Google Forms and Apps Script.
But I have done exactly this with UiApp/Html Service in Apps Script. I used it for a light-duty user authentication.