Spreadsheet Automation 101 - How to Automate Google Sheets · Lesson 27 of 40

Spreadsheet Automation 101 Lesson 3: Email Other People For Loop

Members-only tutorial

Watch the video and get the practice sheet with membership.

Unlock tutorials
Send the same email to different people by using the same Four Loop to figure out which ones we’re sending. Do cool things with this Mail App and email system.
17 formulas linked inline Click any highlighted terms to learn more.

<div>0:00 So in this earlier video, we created a bunch of tasks and then we emailed ourselves or someone else, all the tasks that aren't done.<br>0:09 Well, what if we have multiple people we wanna send emails to? So I created another tab called emails and I have a list of email addresses .<br>0:17 This is all the same, my own email address, just with some dots in it. Now how do we send the same email to all those different people?<br>0:25 Well, we use the same four loop, a similar thing with the four loop. Email Yourself a Cell from a Google Sheet, Every Day Quick Follow Up Email

So just to re re review, we are sending the recipient only one time here to one email address as text.<br>0:37 We'll change that. We're sending them the subject tasks not done, and then we're sending them the array of not done tasks.<br>0:46 We're using this four loop here to figure out which ones we're sending and then we're using this line of code that the whole thing hinges on this one line of code, which is send to a recipient, the subject and the body, which is not done tasks.<br>1:01 Okay? Quick Follow Up Email

So what we need to do is actually put this mail app, the whole reason we have everything above it into a for loop and get the array of all of the emails that we got.<br>1:14 So same thing we do here. We're going to do variable. Let's do this, let's bring this up. We're gonna do variable emails equals or is spreadsheet app.<br>1:28 We wanna do the e sheet name is emails, I do believe emails a, let's just do exactly what we have a one to a four, A one, A four before we do anything else, right?<br>1:45 We can log this logger dot log email list. Let's see what that is. Simply Email Yourself From a Google Sheet Email When Cell Changes

Let's comment out the mail app. So we're not sending emails, but we'll just see what that email list looks like.<br>1:59 We'll run email. Not done. Here we go. So we got an array of arrays . So all we need to do is get first array part, right?<br>2:08 We can also log those. Let's just log it just to be sure we got it correct. We'll do email list with bracket notation as we learned before.<br>2:16 We'll do zero. We'll also do just one. We'll just copy paste this just to double check that we're getting the right thing.<br>2:24 We got the right brackets in the right place. We'll do run. Quick Follow Up Email

And there we go. We got Andre. Different email addresses .<br>2:33 Perfect. So now let's get this into the four loop. Okay, four I equals zero I is less than email list.email list dot length.<br>2:52 We'll do another semicolon and I plus plus. We'll put in brackets. Let's put that bracket up there. We want to send this email and we have variable recipient.<br>3:08 Maybe we'll write email here. Email, we'll change. Maybe we'll change that. Variable r e c. Just make sure that it is changed to email.<br>3:20 Well, what is that variable? It's email equals email list with BRCA notation . Email When Cell Changes

I, okay, so ideally, right we are moving all this just a little bit in, tab it in a little bit so it's easier to read.<br>3:37 We can log the whole list. We can get rid of that log, save it. We're getting all of the emails.<br>3:43 And then we're gonna send an email to each one. And that should end up in our sent. So let's say run.<br>3:49 See if we get any errors. Parameters , number string string . Don't match the method. Signature sent. Email line 20. What does that mean?<br>4:03 The parameters number String . String. Oh, might be because we need to add a zero. Email When Cell Changes

If it looked like those things we logged were actually still arrays and not a string .<br>4:16 So let's see if we just add this BRCA notation zero at the end. So it's the first item, which is an array.<br>4:23 It might only be one item array. We might need to get that one item there. So let's see if that fixes it.<br>4:29 Perfect Execution completed there and they do exist all in our sent folder. Perfect. So we've sent emails now to a bunch of people.<br>4:41 Well, it's all us. We sent those emails to ourselves. But this is a great way. Email When Cell Changes

So you can create a list of emails.<br>4:49 You wanna send maybe a report to every month or every week or every day. I don't know how many people you have to report to.<br>4:56 There are some additional things you can do here that I won't go into this video and won't be in this course, but you can add CC bcc.<br>5:05 You can do some pretty cool things with this mail app and email system. So I hope you can email lots of people the reports that you have to email them anyways, get a lot of stuff done.<br>5:15 Things are watching.</div> Simply Email Yourself From a Google Sheet Automatic Email Report from Google Sheets

Spreadsheet Automation 101: Introduction to Pre-course Videos Think Like a Programmer: Develop The Mindset of an Apps Script Coder How To Change Date Format Automatically Tips to Navigating Thousands of Lines of Code In Apps Script Spreadsheet Automation 101: Functions Spreadsheet Automation 101: Variables Spreadsheet Automation 101: Dot Notation Spreadsheet Automation 101: Camel Case Spreadsheet Automation 101: Parentheses Spreadsheet Automation 101 Lesson 1: GetValue - Introduction to SpreadsheetApp Spreadsheet Automation 101 Lesson 1: Spreadsheet Taxonomy Spreadsheet Automation 101 Lesson 1: A1 Notation vs Row,Column Syntax Spreadsheet Automation 101 Lesson 1: getActiveSpreadsheet() vs getActiveSheet() Spreadsheet Automation 101 Lesson 1: onOpen() Trigger - Custom Menu This Seems Like Automation Spreadsheet Automation 101 Lesson 2: Get Values - Introduction Spreadsheet Automation 101 Lesson 2: Arrays Spreadsheet Automation 101 Lesson 2: For Loop Spreadsheet Automation 101 Lesson 2: Bracket Notation Spreadsheet Automation 101 Lesson 2: Logger.log() Spreadsheet Automation 101 Lesson 2: If ( ){ } and Checkboxes Spreadsheet Automation 101 Lesson 2: onEdit() Trigger Introduction to Spreadsheet Automation 101 Lesson 3 Spreadsheet Automation 101 Lesson 3: MailApp Spreadsheet Automation 101 Lesson 3: Email Yourself For Loop Spreadsheet Automation 101 Lesson 3: Send Email Every Week Trigger Spreadsheet Automation 101 Lesson 3: Email Other People For Loop Spreadsheet Automation 101 Lesson 4: Access APIs Introduction Spreadsheet Automation 101 Lesson 4: UrlFetchApp Spreadsheet Automation 101 Lesson 4: OmdbAPI get ApiKey, get Data in URL Spreadsheet Automation 101 Lesson 4: OmdbAPI get data in Apps Script Spreadsheet Automation 101 Lesson 4: JSON (beautifier) and OmdbAPI parameters Spreadsheet Automation 101 Lesson 4: OmdbAPI Parameter Picker Automatically Clear Content | Refresh Reuse Recycle Templates Automate Google Sheets With Zero Experience Automatically Uncheck A Daily Checklist Activate A Certain Sheet When Opening a Spreadsheet Scoping Functions in Apps Script Breaking Through Errors In Apps Script VAR vs CONST vs CONSTANT in Apps Script