function sendEndOfYearEmails() { var spreadSheet = SpreadsheetApp.getActiveSheet();
var dataRange = spreadSheet.getDataRange();
// Fetch values for each row in the Range.
var data = dataRange.getValues(); var text = 'Detyra ne Cloud Computing:'+ '\n\n';
for (var i = 1; i < data.length; i++) {
(function(val) { var row = data[i]; var emailAddress = row[1]; //position of email header — 1 var name = row[0]; // position of name header — 1 var message = 'Pershendetje ' + name + '\n\n' + text + row[2]; var subject = 'Email Automatik nr 1'; MailApp.sendEmail(emailAddress, subject, message); })(i); } }
Ushtrim 2
// Create a new Google Doc named 'Hello, world!'
var doc = DocumentApp.create('Hello, world!');
// Access the body of the document, then add a paragraph.
doc.getBody().appendParagraph('This document was created by Google Apps Script.');
// Get the URL of the document.
var url = doc.getUrl(); function createAndSendDocument() {
// Get the email address of the active user - that's you.
var email = Session.getActiveUser().getEmail();
// Get the name of the document to use as an email subject line.
var subject = doc.getName();
// Append a new string to the "url" variable to use as an email body.
var body = 'Link to your doc: ' + url;
// Send yourself an email with a link to the document.