Tag Archives: Google Apps Script

Save Gmail Drafts with Google Apps Script

The following Google Script uses the new Gmail API to save a draft messages inside your Gmail mailbox, something which cannot be done using the regular GmailApp service of Google Apps Script.

You’ll have to enable the Gmail API under the Google Services console for this code to work. Credit: yure..@gmail.com

Share Google Drive Files with Apps Script

I wrote a little Google Script that saves Gmail attachments to Drive and shares the saved files with users based on rules defined in the message body itself. Here’s a sample rule:

# view@example.com, v #
# comment2@example.com, comment@example.com, c#
# edit1@example.com, edit2@example.com, e #

In the above case, the file(s) would be shared with all these users but the sharing permissions would be different. The user view@example can only view (v) the document, the users edit@example have editing permissions while others have commenting permissions.

Shorten URLs in Google Documents

Panini has written an add-on for Google Documents that will automatically shorten all the hyperlinks (URLs) in the existing document using the bit.ly API. You’ll need to supply your own Bitly API key to be able to track clicks inside your Bitly dashboard.

A similar approach may be used to shorten links with goo.gl though you would need to enable the Google URL shorterner service from the services console.

Here’s another snippet by Dave Johnson that shortens URLs in Google Docs using the goo.gl service. It works for even ftp URLs and the good thing is that it ignores URLs that are already shortened.

Export Tweets from Twitter with Google Apps Script

The Twitter Archiver app will archive tweets for any hashtag to a Google Spreadsheet using the Twitter API and Google Apps Script.

You can set a time-based trigger to run downloadTweets() every 5 minutes or even 1 minute for hash tags that are extremely popular.

How to Learn Google Apps Script

The best resource for learning Google Script is the official documentation available at developers.google.com. Here are other learning resources where you can get up to speed using Google Apps Script.

Also see: How to Learn Programming Online

  1. Awesome Google Scripts by +Amit Agarwal
  2. Case Studies – Sample Google Script Projects (google.com)
  3. Google Apps Scripts – Snippets
  4. scoop.it/t/gas by +Martin Hawksey
  5. O’Reilly – Apps Script – by +James Ferreira
  6. Apps Script Webinars – YouTube – by +Eric Koleda
  7. scriptsexamples – by +James Ferreira +Romain Vialard
  8. StackOverflow Q&A – Got a question? Ask here.
  9. lynda.com – Scott Simpson (Up and Running with Google Scripts)
  10. Tutorial – Written Google Docs Addons
  11. Known Issues & Bugs – Report a bug here.

This list is maintained by Amit Agarwal. Send me a tweet @labnol to suggest another resource.

Sell Digital Downloads with Google Scripts

You can set up your own digital shop on the Internet with the help of PayPal and Google Scripts. You upload your file on Google Drive, the buyer makes a purchase through PayPal and Google Apps Script will deliver the file to the buyer through Gmail.

See: Sell Digital Products Online