Advertisement
Guest User

Untitled

a guest
Apr 19th, 2015
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. function createAndSendDocument() {
  2. // Create a new Google Doc named 'Hello, world!'
  3. var doc = DocumentApp.create('Hello, world!');
  4.  
  5. // Access the body of the document, then add a paragraph.
  6. doc.getBody().appendParagraph('This document was created by Google Apps Script.');
  7.  
  8. // Get the URL of the document.
  9. var url = doc.getUrl();
  10.  
  11. // Get the email address of the active user - that's you.
  12. var email = Session.getActiveUser().getEmail();
  13.  
  14. // Get the name of the document to use as an email subject line.
  15. var subject = doc.getName();
  16.  
  17. // Append a new string to the "url" variable to use as an email body.
  18. var body = 'Link to your doc: ' + url;
  19.  
  20. // Send yourself an email with a link to the document.
  21. GmailApp.sendEmail(email, subject, body);
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement