Тёмный

Google Forms Confirmation Email with Attachment |Google Apps 

Jeff Everhart
Подписаться 3,9 тыс.
Просмотров 24 тыс.
50% 1

Click here for step-by-step directions: www.jeffreyeverhart.com/2015/0...
In this sort tutorial we will walk through how to extend a Google Form to make it send PDF attachments along with a confirmation email. This tutorial builds on the ideas of part 1, so be sure to check that out. Pose any questions with code in the comments below or on my blog. Cheers!

Хобби

Опубликовано:

 

29 янв 2015

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 106   
@ohmygapped
@ohmygapped 4 года назад
almost 5 years later this still almost works 100%. i had to activate Google Drive API to make it work. thanks, Jeff!
@jeffeverhart
@jeffeverhart 3 года назад
Sorry for the late reply, but thanks for watching!
@angelv1393
@angelv1393 4 года назад
May 2020 and still working. Thank you very much for this wonderful tutorial.
@jeffeverhart
@jeffeverhart 4 года назад
Awesome! The fundamentals don't change all that month since Apps Script is so stable.
@felizmentelena
@felizmentelena 8 лет назад
Thanks a lot for posting this Jeff! you literaly save my life! Big thaaanks :)
@jeffeverhart
@jeffeverhart 8 лет назад
+Elena Alcalde Thanks for watching! Check out my blog linked in the video description for other cool things you can do with Google apps.
@tim_ash
@tim_ash 2 года назад
Very helpful! What do I do if the attachment that I want to send is based on a multiple choice selection in the form?
@xromium
@xromium 7 лет назад
Thanks a lot! Great stuff!
@jeffeverhart
@jeffeverhart 7 лет назад
Thanks for watching!
@stephenanderson7539
@stephenanderson7539 3 года назад
Jeff, First Thanks. I am wondering how to combine this attachment with an earlier video that you posted on how to auto generate a google doc from a google form? I want the attachment to be the form that is created in that script to be able to mail a copy of what gets created to the email of the person that submitted the form. FYI using the other script for book reports from elementary students.
@tomahawkdiving8679
@tomahawkdiving8679 8 лет назад
I got it Jeff. I had the doc ID wrong. Thanks!!! This was my first script!!! Off to break something else....
@jeffeverhart
@jeffeverhart 8 лет назад
+Tomahawk Diving Very cool. Glad you got it to work! Thanks for watching.
@buddhikapriyasad4571
@buddhikapriyasad4571 7 лет назад
Dear Jeff Everhart, How to attach specific tab (one sheet) from Google sheet Thank You,
@sharifabdulrahmansharifhas6607
Do I need to use the paid version of Cloud to enable the conversion of docx to pdf? So far, I've got this issue - Converting from application/vnd.google-apps.document to undefined is not supported. (line 27, file "Code") --
@dataselection3288
@dataselection3288 6 лет назад
Hi Jeff- is there any possibility to do the following:When someone attaches a file to google form and press submit, I get an email notification saying X person has submitted a form. On that email confirmation, could I possibly get the attached document that the person has submitted as well?Cheers!C
@ThomasMwadime
@ThomasMwadime 9 лет назад
Hi Jeff, thanks for both videos on this. Really useful. Im having a small problem in that i'd like my trigger to be 'upon edit'. I.e. to send the email if i edit the response spreadsheet. Is that possible? And is it possible to add a confirmation pop up before the email is sent upon editing the spreadsheet?
@jeffeverhart
@jeffeverhart 9 лет назад
+Thomas Mwadime Hey Thomas, according to the docs, there is an onEdit trigger, but that might fire everytime you make a change, not just a change to one column: developers.google.com/apps-script/guides/triggers/ Not sure about the pop up, as that is outside the scope of what I do in Google Docs, but I'm sure you could find some good resources on Stack Overflow to get you started.
@VogelaarVredehof
@VogelaarVredehof 2 года назад
Hi Jeff, nice video Thanks for that. 1 question: is it also possible to send all questions AND all answers of the questionnair in PDF to the respondent?
@ankitbhurane2
@ankitbhurane2 8 лет назад
How to send the filled form itself as an attachment?
@fab99fab
@fab99fab 7 лет назад
what is the code for sending an excel file as an attachment ?
@tomahawkdiving8679
@tomahawkdiving8679 8 лет назад
Jeff thanks for putting this up here!! I'm running in to a snag. Not sure what I'm screwing up... When I submit a test form response with my email address I'm not getting the email. I've set the trigger to run on form submission. Here is the code I used: function confirmationEmail(e) { var lastName = e.values[1]; var firstName = e.values[2]; var primaryEmail = e.values[9]; var waiver = DriveApp.getFilesByName("TD Waivers PDF"); var subject = "Welcome to the Group!!!"; var body = "Thanks for registering " + firstName + " for the Group. Please print the attached waiver. Sign, scan, and email it back to us if you have not done so already. Thanks!!!"; MailApp.sendEmail(primaryEmail, subject, body, {attachments:[waiver]}); }
@jeffeverhart
@jeffeverhart 8 лет назад
+Tomahawk Diving Hmm, everything looks alright. Set error notifications to send immediately and let me know what you receive.
@magnumveritas9526
@magnumveritas9526 4 года назад
Super helpful stuff. Thank you Jeff. I'm getting an error however. My script has failed to finish successfully because I do not have permission to call DriveApp.getFileById. Required permissions. What do I do?
@jeffeverhart
@jeffeverhart 4 года назад
That error displays when you don't have permission on that file. I'd request access from the owner of the file, and then you shouldn't see that error anymore.
@calebb.2335
@calebb.2335 4 года назад
@@jeffeverhart Thank you. It seems that I needed to log out of that gmail account and then it worked. Your code was perfect though. Thank you so much.
@dianesierra8617
@dianesierra8617 9 лет назад
Hi Jeff, can more than one attachment be added? Thanks in advance for your response.
@jeffeverhart
@jeffeverhart 9 лет назад
Diane Sierra According to the documentation, yes. Take a look at the example here. It looks like you just pass the two attachments into an array. developers.google.com/apps-script/reference/mail/mail-app#sendEmail(String,String,String,Object)
@sudarshanms7822
@sudarshanms7822 8 лет назад
How do I customize the response form? I wish to use Eventname big font size ,colour & slogan with small font size, colour with my logo. A auto generation recipient ID. in " pdf " Thanks ...sudarshan
@jeffeverhart
@jeffeverhart 8 лет назад
All of the customization options for Google forms should be in the UI for the form itself. Not sure it lets you change fonts, but will support uploaded images.
@SegueoPIXJustoDantas
@SegueoPIXJustoDantas 8 лет назад
Parabéns. Agora falta apenas um tutorial de como enviar uma sequência de e-mails personalizadas.
@jeffeverhart
@jeffeverhart 8 лет назад
+Justo Dantas - Ousar com Responsabilidade Obrigado! Vou trabalhar nisso no futuro!
@soeminlatt3302
@soeminlatt3302 8 лет назад
Hi,Jeff. please upload how to send verification code to user gmail with google mail form.Thanks.
@jeffeverhart
@jeffeverhart 8 лет назад
+Soe Min Latt Where is the code coming from?
@monicahwanjiru6455
@monicahwanjiru6455 8 лет назад
Hey Jeff,thank you so much for this tutorial. Do you ha an idea on how to make form response notification be a PDF attachment (this is what I mean: when a form is filled an submitted,I get an email notification with a PDF attachment) Is this possible? Thank you
@jeffeverhart
@jeffeverhart 8 лет назад
Yup, just follow the same steps outlined here, but send the mail to you instead of another person.
@monicahwanjiru6455
@monicahwanjiru6455 8 лет назад
+Jeff Everhart Thank you.
@jeffeverhart
@jeffeverhart 8 лет назад
You're welcome! Thanks for watching
@AndrewWoodward597
@AndrewWoodward597 9 лет назад
Thank you Jeff I really liked your video, have not tried yet but am after seeing your video, could i ask if it is possible to send an email from a conditional formating trigger? Am trying to send an email to students saying they have not handed in there work after a due date. can you help ?
@jeffeverhart
@jeffeverhart 9 лет назад
I don't know that you can set up a conditional trigger, but you could always set up a time driven trigger (to run after the due date) that could include some conditional logic. The programming would be different than this video though. You would need to loop over the spreadsheet and add the student who've submitted to an array, then compare those students to the whole class and then run the function if they don't appear in the completed array. Let me know if I can help to find some specific resources to get started. Always happy to help out a fellow educator! Cheers, JE
@AndrewWoodward597
@AndrewWoodward597 9 лет назад
Great thank you will try.
@AndrewWoodward597
@AndrewWoodward597 9 лет назад
Andrew Woodward Hello Jeff I would be grateful if you could point me at a starting place, I am trying to get the students to own their work more by being sign posted about where they are in their learning. Thank you for your support. Kindest regards Andy
@gujaratmun1859
@gujaratmun1859 7 лет назад
hello, following error is poped up ReferenceError: “Mimetype” is not defined. (line 7, file “Code”) i want to send a pdf from my google drive
@jeffeverhart
@jeffeverhart 7 лет назад
Check to make sure the line of code that specifies the Mime Type is accurate with what is here: jeffreyeverhart.com/2015/01/30/tech-tip-google-forms-confirmation-email-with-attachments/ I'd assume that capitalization matters here: MimeType.PDF
@basilioguevarrajr6604
@basilioguevarrajr6604 9 лет назад
Hey man, i'm really thankful i see your channel, but can you teach me how to put status on the spreadsheet Example: Name | Address | Age | Email | Status| status indicate if the mail has been sent or not.
@jeffeverhart
@jeffeverhart 9 лет назад
Random Videos Sorry for the delayed reply, but you can just do that by manually accessing the spreadsheet range and putting the value in the final cell of the row you just modified: developers.google.com/apps-script/reference/spreadsheet/range
@jeffeverhart
@jeffeverhart 9 лет назад
Random Videos Also check out get last row and get last column on the sheets app here: developers.google.com/apps-script/reference/spreadsheet/sheet
@halane7075
@halane7075 8 лет назад
Hi Jeff, Thank you so much for this video. It helped me completing my google from. However, I have one question that I couldn't find an answer to it anywhere. How can I create a Table to be filled in by the user in google form? How can I create a script that creates this table? The table looks something similar to the following: FY10 FY11 FY12 Total Cost of Item 1 -------- -------- -------- Total Cost of Item 2 -------- -------- -------- Total Revenues from Department A -------- -------- -------- where "------" needs the user's input. Also, Can I find the responses to the survey in a google spreadsheet? I would greatly appreciate your help on how to solve this or where I can find more information. This is the first time I use google docs and I would greatly appreciate any help on this!! Thank you so much!
@jeffeverhart
@jeffeverhart 8 лет назад
+Hala NE You can generate an email from the spreadsheet submission as I've shown here and populate the table as HTML in the email. You would just need to create an HTML table with spots in it for the variables submitted on the form. Other tutorial on sending email: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-GuFZ78_NZtQ.html See this link on sending HTML body: developers.google.com/apps-script/reference/mail/mail-app#sendEmail(String,String,String,Object)
@pewpewpops
@pewpewpops 9 лет назад
Thanks man:) With the limitations on email I am having to go with using an html form to gather info from the user, have a php script send there info to a mySQL database and send out an email to the user. Are you familiar with using php and mySQL? This is what I am wanting to do. 1. Have the user fill out the form. 2. On submit there contact info will go to the mySQL database. 3. Also on submit the users will be redirected to a page and an email will go out to them. Any help would be so rad!
@jeffeverhart
@jeffeverhart 9 лет назад
HomeScienceIdeas.com I have a bit of PHP and mySQL experience, so let me know if you want me to look at your code. PHP has a built in mail function. You can read about it here: stackoverflow.com/questions/5335273/how-to-send-an-email-using-php Basically, we are doing the same thing programmatically in PHP as in the tutorial for Google Apps. Create some PHP variables to hold POST data from HTML form. Transmit those same variables to the SQL database, and then populate an email with those variables and some other options if you want. Sometimes your hosting service may have some additional options of PHP plugins.
@pewpewpops
@pewpewpops 9 лет назад
Right now I have a sort of Frankenstein code put together. It works a bit like I want it to but it is missing some stuff. It will send one part (email) to my database but not the name. It is a mix of two peoples code so I am trying to cut stuff out I don't need and put it what I do need but when I do that I get errors. WRONG CODE! See post below this one for the code...
@pewpewpops
@pewpewpops 9 лет назад
I left out my database info but it connects:) My two tables in my database are "username" and "email". When I submit the form it will grab the "email" but it does not grab the "username". SORRY! That code was wrong:( HERE IS THE RIGHT CODE:
@pewpewpops
@pewpewpops 9 лет назад
Here is the form: homefarmideas.com/phptest/Sendemail.html
@jeffeverhart
@jeffeverhart 9 лет назад
HomeScienceIdeas.com In you SQL statement you try to transfer the value "$_POST[username]' into the table, but everywhere else it is $first_name or $last_name. When I viewed source on the HTML form there was no input for username. Switch this to either first name, last name or a variable that concatenates both first and last name for the username. Try that and let me know how it works out!
@rickdeloach3708
@rickdeloach3708 9 лет назад
Jeff: I need for form users to submit an attachment. Have you tried having the user enter the document ID (or full document URL) of one of their documents (shared to all as view only) and have the app script send that document as a PDF?
@jeffeverhart
@jeffeverhart 9 лет назад
Rick DeLoach Hey Rick: That is a really interesting problem. I've never tried that, but there is one draw back. When you create the script, it asks you to authorize access to your drive, so I'm not sure how it would work to get a document out of someone else's drive. It might work because it is shared with you, but it would be worth a test drive. Another alternative would be to format the message as HTML and display the link or document URL in the body of the email. Do you want to try coding up an example and post it here or on my blog so we can troubleshoot?
@rickdeloach3708
@rickdeloach3708 9 лет назад
Jeff Everhart The code below sends the output of my form to a defined distribution list as BCC in email AND saves a PDF version on a defined drive location. The code is below. Ideally, I need the user to submit an attachment that goes to the BCC distribution. These are all internal users so the document should be view permissions for anyone with the link. Here's the code I cobbled together from different sources (I'm not a developer). /* Send Google Form by Email v2.1 */ // www.labnol.org/internet/google-docs-email-form/20884/ /* For customization, contact the developer at amit@labnol.org */ /* Tutorial: www.labnol.org/?p=20884 */ function Initialize() { var triggers = ScriptApp.getProjectTriggers(); for(var i in triggers) { ScriptApp.deleteTrigger(triggers[i]); } ScriptApp.newTrigger("SendGoogleForm") .forSpreadsheet(SpreadsheetApp.getActiveSpreadsheet()) .onFormSubmit() .create(); } function SendGoogleForm(e) { try { // You may replace this with another email address var email = Session.getActiveUser().getEmail(); var bccs = 'rdeloach@rentpath.com' var s = SpreadsheetApp.getActiveSheet(); var columns = s.getRange(1,1,1,s.getLastColumn()).getValues()[0]; var message = "ANNUAL VENDOR ASSESSMENT"; // Only include form fields that are not blank for ( var keys in columns ) { var key = columns[keys]; if ( e.namedValues[key] ) { message += key + ': ' var answer = ""; var answer = e.namedValues[key].toString(); //Replace with in rest of text var answer = answer.replace(/ /g, ''); message += answer + ""; // + e.namedValues[key] + ""; if (key=="Service Provider Name") { var Vendor = e.namedValues[key] ; } } } //Add Footer message += "=================================================================================" message += "All Annual Vendor Assessments can be found in this directory." // This is the MailApp service of Google Apps Script // that sends the email. You can also use GmailApp for HTML Mail. // Optional but change the following variable // to have a custom subject for Google Form email notifications var subject = "Annual Vendor Assessment for: "+Vendor; GmailApp.sendEmail(email, subject, message, {bcc:bccs, htmlBody:message}); //Save as PDF in folder var filename = 'AVA-'+Vendor+'.PDF' htmlToPDF(message,filename); } catch (e) { Logger.log(e.toString()); } } function htmlToPDF(html, filename) { var dir = DriveApp.getFoldersByName("Annual Vendor Assessments").next(); var blob = Utilities.newBlob(html, "text/html", "text.html"); var pdf = blob.getAs("application/pdf"); dir.createFile(pdf).setName(filename); }
@rickdeloach3708
@rickdeloach3708 9 лет назад
Rick DeLoach Jeff Everhart It was easier than I thought - but I still need to test permissions. The assumption is the file is shared to everyone in the organization with view access. In the form, I ask the user to give me the google doc ID. Then I just use the DriveApp.getFileByID(fileID) command and use that in the GmailApp.sendEmail command ..attachments:[fileID] It don't even convert to PDF because that was failing (oddly enough) on certain file types.
@jeffeverhart
@jeffeverhart 9 лет назад
Ok, cool. Yes, if the whole org uses Google Drive, then converting to PDF is unnecessary. Not sure what your audience is for this, but it might be helpful to add some help text about finding the document ID if you haven't already. If they end up putting something other than the actual ID, you'll end up with a lot of errors.
@matejstanovsky3760
@matejstanovsky3760 9 лет назад
Hi Jeff, i have question... Confirmation email works for me properly, script does not work any more. i followed all steps on link.any idea
@jeffeverhart
@jeffeverhart 9 лет назад
Matej Stanovský If the email still sends, what part of the script is not working? Can you post the code you're using here or on my blog so that I can take a look? Thxs
@GASecurityLtdDarlington
@GASecurityLtdDarlington 9 лет назад
this is exactly what i need :) is it possible to send the filled out form as a PDF to email Many thanks
@jeffeverhart
@jeffeverhart 9 лет назад
G&A Security NE Ltd It is, but that requires a few more steps and isn't something that I can explain in the comments. If you give me a few days, I can create another video explaining how to do it.
@GASecurityLtdDarlington
@GASecurityLtdDarlington 9 лет назад
Jeff Everhart that would be great go slow please haha is their any way you take donations if that works you will have saved me and my company loads of time. bit cheeky but can it also be sent to a printer that is connected to the internet , is that possible also ? Thanks again your a star
@GASecurityLtdDarlington
@GASecurityLtdDarlington 9 лет назад
all i need to send to printer is the email so that simple enough, can not wait for this video Jeff Everhart :D
@GASecurityLtdDarlington
@GASecurityLtdDarlington 9 лет назад
Jeff Everhart have you had any luck ? many thanks
@prasanthkumarg3651
@prasanthkumarg3651 4 года назад
100 th like 🙂🙂🙂
@jeffeverhart
@jeffeverhart 3 года назад
Awesome! Thanks for watching!
@saddlebroncSilver
@saddlebroncSilver 8 лет назад
Mrs. Jeff, thanks a lot for those couple video about this question, so how could be possible I to do this little different, instead send automatic the PDF file after submission, the PDF file will be triggered after paypal payment, so paypal have an option to set a link after payment, so how could I figure out it, could you help me figure out my mind with it please, regards.
@jeffeverhart
@jeffeverhart 8 лет назад
+Rodrigo Costa (rodricosta) Hello Rodrigo, I'm sure that's something you'd want to do with Google Apps Script, and if you did you'd need to build a fully functioning web app to do it. Since we are only editing things in the script editor of the spreadsheet, we don't really have access to other things outside the Google ecosystem this way. I might try looking for another tutorial that teaches you how to build a payment processing system in PHP instead, as this sounds more like what you are looking for. Thanks for watching!
@saddlebroncSilver
@saddlebroncSilver 8 лет назад
First of all, thank you pretty much for the answer, yes PHP make more sense . So I'm looking all kind of things I could to do with Google platform. Another thing, instead PDF could I set slide presentation or videos, to be send automatic after form submission??? Thanks once again for your time and help , I really appreciate sir, regards.
@jeffeverhart
@jeffeverhart 8 лет назад
You should be able to do that. Instead of getting the file as a mime type pdf, you can get it as a mime type MICROSOFT_POWERPOINT, as outlined in the docs here: developers.google.com/apps-script/reference/base/mime-type Let me know how that works out.
@saddlebroncSilver
@saddlebroncSilver 8 лет назад
Hi sir, yap, but I have to type MICROSOFT_POWERPOINT so google have the similar tool , the slide presentation. so I'm working in my project and I was finish figure out some error I was , so I'll test those your script now and see how works here for me, one more thing, I have already a script working in my spreadsheet editor and that script allow me receive response in my spreadsheet and gmail at same time , this is really nice and I want keep it, so any problem if I add another function script in the same spreadsheet editor, sorry I'm so raw with java script , I was reading little about in w3school to understand better, but I don't much , so if I can use more than one script function in the same spreadsheet editor , how to separate those script to each one work fine. thanks alot sir, I appreciate , you have help me alot. thanks. regards.
@saddlebroncSilver
@saddlebroncSilver 8 лет назад
Ok, =) take example of your code , I have to change just some script lines and that should work. var docs = DriveApp.getFilesByType(MimeType.GOOGLE_SLIDE); while (docs.hasNext()) { var doc = docs.next(); Logger.log(doc.getName()) }
@hhkgenset829
@hhkgenset829 9 лет назад
Hey Jeff, hope you are doing well.. dear i am unable to attached the Word Document File. pls help me out
@hhkgenset829
@hhkgenset829 9 лет назад
I am using the following script... function myFunction(e) { var Name = e.values[1]; var Email = e.values[9]; var subject = "LSU Membership Confirmation"; var message = "Thank you, " + Name + " for choosing LSU CSI Services "; var waiver = DriveApp.getFileById("1jc-USEBFjI_z7-3zmCBuMVQSmvSxFijNYx6-wz0H_XU"); var liabilityWaiver = waiver.getAs(MimeType.GOOGLE_DOCS); MailApp.sendEmail(Email, subject, message, {attachments:[liabilityWaiver]}); }
@anaroman1499
@anaroman1499 9 лет назад
I tried every step but no email response.
@emilytatum4365
@emilytatum4365 8 лет назад
Thanks so much for posting this tutorial! I think that I have completed the coding correctly but the attachment is still not coming through with my confirmation email. Here is the code that I put in: function myFunction(e){ var userName = e.values[1]; var userEmail = e.values[2]; var subject = "Survey Completed"; var message = "Thank you, " + userName + ", for completing our Speaker Feedback survey for the Dark Side of the Full Moon event. Attached is your certificate of completion for CEUs. Have a great day!"; var certificate = DriveApp.getFolderById("1kku5tG_zFpr-S4BrSe7YA8XS1FOxDF-eW9pa_C3PGW4"); var certofcompletion = certificate.getFilesByType(MimeType.PDF); MailApp.sendEmail(userEmail, subject, message, {attachment:[certofcompletion]}); }
@jeffeverhart
@jeffeverhart 8 лет назад
+Emily Tatum It looks like the getFilesByType returns a collection of files, not just one file: developers.google.com/apps-script/reference/drive/drive-app?hl=en#getFilesByType(String) Why don't you just grab the single certificate file by ID?: developers.google.com/apps-script/reference/drive/drive-app?hl=en#getFileById(String) That way, you know that you are getting the one, singular file you need. Try that and let me know if it works or if there is some reason you need to get the collection of files.
@jeffeverhart
@jeffeverhart 8 лет назад
+Emily Tatum The certificate variable you created is a folder, not a file. Use getFileById instead with certificate and that should work with what you have here.
@piyushghiya3085
@piyushghiya3085 7 лет назад
Hello, I want to add a hyperlink to be attached in my confirmation body like "to make payment CLICK HERE" and when any one clicks on "click here" he or she shall be navigated to a link. Kindly guide me through it.
@jeffeverhart
@jeffeverhart 7 лет назад
You will need to make an HTML email using the htmlBody advanced parameter here:developers.google.com/apps-script/reference/mail/mail-app#sendEmail(String,String,String,Object)
@piyushghiya3085
@piyushghiya3085 7 лет назад
Hey Jeff, I have gone through entire blog, but I am unable to track code for converting string to hyperlink. It would be great if you can send the code of just this, currently I am sending an auto reply with attachments, as per you tutorial. Regards, Piyush Ghiya
@pranupranav5563
@pranupranav5563 3 года назад
It is not working.
Далее
How to Auto-Send Emails on a Google Form Submission
19:54
best way out of the labyrinth🌀🗝️🔝
00:17
Просмотров 1,4 млн
How To Send Email Attachments with Google Apps Script
10:42
How to send a confirmation email with Google Forms
6:51
Google Forms - Google Drive's Hidden Gem
13:37
Просмотров 494 тыс.
Introduction to Google Apps Script
35:40
Просмотров 130 тыс.
JPEG is Dying - And that's a bad thing
8:09
Просмотров 13 тыс.
Как быстро охладить арбуз
0:31