Quickly Create an Automatic Daily Email with Motivational Quote
Learn how to automate daily emails with a motivational quote using Google Apps Script. This tutorial guides you through the process of setting up a script that sends a random quote to your email every day.
In a previous video, I showed you this list of motivational quotes, spreadsheet quotes, famous spreadsheet quotes, and how we got them onto this website, randomquote.card.co. And every time we refresh it, we're going to get a brand new spreadsheet quote from this list. But what if you wanted to keep this private or you wanted to send this to a very special person, maybe yourself. So I want to show you how to do that in this video. We're going to go to, okay. App script , extensions app script . Open it up and we already have the embed code from the last video here. We don't need that. And we have the code already to get a random quote, but how do we email it to ourselves? The key here is we do not need the do get function , but we do want function email daily. And this is pretty simple. We're going to use at the end mail app, send email. And the send email function is only gonna. Email Myself a Daily Random Motivational Quote Why do I want to Email Myself Every Day? Email Myself a Daily Random Motivational Quote Quickly Build a Daily Random Motivational Quote Website
Take three things. We need a two, someone sending it, who we're sending it to. We need a subject and a body of that message. The two will be us, which whenever you're using this app script , we can do variable two equals, I think it's going to be session dot get active user. This should get a email address of the user. We can always check this out by doing logger dot log two, and we can See, if that is the case, we will also use variable subject, we can put the random quote here if we want, or we can put it in the body or both. So actually I'm going to put in both the body and the subject. And see how that goes. So when we run this for the first time, we're going to have to approve it, but we're going to see if we want to see this logger, if this session Email Myself a Daily Random Motivational Quote Email Yourself a Cell from a Google Sheet, Every Day Email Myself a Daily Random Motivational Quote Email When Cell Changes
dot get active user is really getting just the email address of whoever is creating this Apps Script , which in our case, it's going to be us. Once we authorize it it came back with this email. Perfect. It is exactly me. This session dot get active users getting our email address, but we do have an issue with get random quote. I think we're getting, I think we need two string . I think, let's see if this might be too much. Let's try to run it again. Oh, actually, I think the issue is, we need to, to string the dot two, two dot two string . I think that's the issue here. Or, actually, we just need get email. We don't need to string , sorry. Email Myself a Daily Random Motivational Quote Who Can I Email From a Google Sheet
That was weird. But now we should just get email, and if we run it, we shouldn't get that error . Perfect. So if we checked our email, we can see it. And this is what our email looks like. The subject is the quote and the body is the quote is actually a different quote in this case. So what we can do is change this subject to today's quote. We can even add new date to make it a different, absolutely different subject each and every time. We're going to save that and run it. And here we see this un formatted date is here. So we can always format this date in a nicer way. We're going to wrap it with utilities dot format date. We're just going to give it a format here. We want month, month. Actually we want day, day, M, M year, year, and we need to end the parentheses here. Email Myself a Daily Random Motivational Quote Writer Better Prompts Email When Cell Changes
And let's see if that works again. And I think we need to use GMT here. And Maybe this. So now let's see if this works. We'll save it. Make sure it's saved. This orange button is going away. We'll run it and should have an email. Perfect. Our date is formatted well and we only have one quote here. Perfect. We're getting a random quote emailed to us. But now, how do we do this every day? Email Daily is only going to run when we click Run Function . Well, what we can do here is go over to the left and click on Triggers. We can go to the bottom right, Add Trigger . And we're going to choose which function to run. In our case, it's going to be Email Daily. And the Event Source, instead of from Spreadsheet , we're going to use Time Driven. We want to Do it every day. So we'll use day timer and we'll set a time period. Email Myself a Daily Random Motivational Quote Email Yourself a Cell from a Google Sheet, Every Day I Created an Automatic Emailer Daily Countdown Email from Google Sheets
In our case, we want it before we start work. So something around 5 a. m. to 6 a. m. You pick an hour and the very first time it runs, it'll be a completely random time within that hour. And then every time after that, it'll be 24 hours later. So we'll hit save. And now I'll get an email every day giving me that motivational quote, a random one every day until I turn off this trigger . If you're looking for the code and the quotes as well, if you'd like the quotes, check out the sheet down below. If you're on BetterSheets, if you're not on BetterSheets and watching this, go join BetterSheets.co and get the sheet and the script all together, everything all at once. Email Myself a Daily Random Motivational Quote Email Yourself a Cell from a Google Sheet, Every Day Email Myself a Daily Random Motivational Quote Simple Daily Reminder Email in Google Sheets