Monday, March 9, 2015
Gmail and Document Services now available in Apps Script
GmailApp
- read, label and send emails
The new GmailApp
should be instantly familiar if you’re used to using Gmail. You have access to labels, threads, and messages, and you can do all the things you expect: change labels, add and remove stars, mark things as important or trash or spam. You can also use the GmailApp.search()
method to do any search you can do in Gmail itself. This is the first full fidelity API to Gmail, and we’re excited to see what you all will do with it.To make sure your Gmail account remains private and secure, we are extra cautious about any script that uses
GmailApp
. Any time you change the code for a script that accesses Gmail, we will require you to reauthorize the script to run. Keep that in mind when editing a script that runs on a trigger - if you don’t reauthorize it, it will fail the next time the trigger tries to run it.DocumentApp
- create and edit Docs
The new DocumentApp
lets you create new documents or open existing ones by id. The id of a document is always in the URL you see when visiting it, and document ids are consistent between DocumentApp
and the existing DocsList service, so you can use DocsList.find()
to search for a document, and then get its id from File.getId()
. Once you have a document, you can access all of its individual elements. You can do search and replace (great for mail merge!), change styles or text, add or remove tables and lists, and much more. And when you are done, you can call
Document.saveAndClose()
, which makes sure all of your changes to the document get saved. If you don’t call it, we’ll do it for you at the end of the script, but it can be useful to call it yourself if you’d like to do something with the document after making your edits.GmailApp
and DocumentApp
are available to all Apps Script users right now. Now the only question is, what are you going to build with them?Posted by Corey Goldfeder, Google Apps Script Team
Want to weigh in on this topic? Discuss on Buzz
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.