Email images to a Google Sites (via a shared Google Drive folder)

The other day a fellow GCT asked if she could have students take pictures and then email them to a Google Site.  I came up with the idea of an embedded (and shared) Google Drive folder that receives images using a Google Script written by Amit Agarwal.  This has really inspired me to learn how to use Google Script and see what i can do with it.  In the meantime, here are the instructions I wrote.

You can setup the ability to send attachments to a shared Google Drive folder which you can them embed into your website.  Here are the steps.

1)  Create a filter that will apply a label to emails that meet the requirements. I created a filter that required an attachment and “WS” in the subject line.  I used the label “Drive” to identify the emails that meet this requirement

2)  Download this Google Sheet by Amit Agarwal

https://docs.google.com/spreadsheets/d/1nHy5LWWCGxqTdpI_1OfJ9dD6xQyi7G7RtCmNfTnGbXI/copy

On the first page of this Google Sheet you will need to fill out cells D4, D5 and D6.  Cell D4 is the label you just identified when you created your filter, in my case “Drive”.  Cell D5 is the folder that the script will create to store my attachments, I use “Website”.  Cell D6 is an additional label to identify that the transfer has occurred, I use “Moved-to-Drive”.

Within this sheet is a self contained script (nothing will be shared outside of your account) that when setup will look for the “Drive” label, will take the attachment and copy it to “Website” folder and will add the “Moved-to-Website” label to the email.

3)  I like to have the script run more often than every 15 minutes (or 2 minutes after a prior trigger event), so I go to Tools-Script Editor and find these two lines of code:

ScriptApp.newTrigger(“sendToGoogleDrive”).timeBased().everyMinutes(15).create();

ScriptApp.newTrigger(“sendToGoogleDrive”).timeBased().after(1000*60*2).create();

And change them to this

ScriptApp.newTrigger(“sendToGoogleDrive”).timeBased().everyMinutes(1).create();

ScriptApp.newTrigger(“sendToGoogleDrive”).timeBased().after(1000*60).create();

Now the code runs every minute (1000*60 is for a minute in milliseconds)

4)  Save the code, and close the tab

5)  Now you need to run the script from the Google Sheet, so go to Gmail Attachments and run Step 1 (approve the permissions) and Step 2 (start the Script)

6)  Send yourself a sample image making sure to have “WS” in the subject line, and to attach an image (you cannot just drag the image into the email, you must attach)

7)  After a minute, the script will create the folder and place your attachment in the folder

8)  Now you can share the folder publicly, and insert folder into your website

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s