9

I'm building a form using GDocs, and then taking the form out into my web page so I can directly edit the form (so I do have complete control over the form code).

Right now I'm able to submit the results send to Google Docs, and then have the results emailed me to me.

I want to add a file attachment to these submissions, using:

<input type="file" name="datafile" id="filedata" size="40">

I know I can use mailApp.sendEmail's advanced arguments, specifically the attachments argument, or the inlineImages argument.

But how do I access the file values in order to attach them to send?

Rubén
  • 34,714
  • 9
  • 70
  • 166
David K
  • 138
  • 1
  • 1
  • 6
  • Is the user submitting a file through your Google Form? I do not believe this is possible with Google Forms. – Phil Bozak Feb 15 '13 at 22:25
  • This is something I'd like to be able to do, even if that file isn't stored in Google. If you look at the first link in my post, you can extricate the form out of the "official" GDocs form, then manipulate the form html however you'd like, even by adding form fields. – David K Feb 20 '13 at 20:22
  • have your modified code store the file as a URL. The user would need to have the attachment already somewhere on a public url. Then just use urlFetchApp to get it as a blob and attach to email. If you want something more complex like allowing the user to chose a file from their device, its way harder as you need code and authentication to save the attachments somewhere you can get them later. – Zig Mandel Jan 06 '15 at 06:15
  • The code on the second linked article use DocList ([tag:google-docs-api]), a Google Apps Script that is now deprecated. – Rubén Dec 23 '17 at 23:18
  • Possible duplicate of [Google Forms: Sending with Attachments (getFileById)](https://stackoverflow.com/questions/41875637/google-forms-sending-with-attachments-getfilebyid) – Rubén Dec 23 '17 at 23:30
  • I'm not able to follow. When/where/how is the user uploading the file? Are you using Google Forms or are you building your own form somewhere? – IMTheNachoMan Mar 23 '20 at 04:57
  • If you're using a Google Form, then the form will tell you the file IDs of the uploaded files. You can use that to attach them to an email. – IMTheNachoMan Mar 23 '20 at 04:57

0 Answers0