Hey there stranger!

Sign up to get access.

Email Myself a Daily Random Motivational Quote

About this Tutorial

Quickly make a daily email to myself with a motivational quote.

Video Transcript

0:00 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.
0:16 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.
0:25 We're going to go to 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.
0:32 code already to get a random quote, but how do we email it to ourselves? The key here is we do not need the doGet function, but we do want function emailDigly.
0:43 And this is pretty simple, we're going to use at the end mailApp.sendEmail. And the sendEmail function is only going to take three things.
0:52 We need a to, someone sending it, who we're sending it to, we need a subject, and a body of that message.
0:58 The to will be us, which ah whenever you're using this Apps Script. We can do variable to equals, I think it's going to be session.getActiveUser.
1:10 This should get a email address of the user. We can always check this out by doing logger.log to and we can see if that is the case.
1:20 use variable subject. We can put the random quote here if we want or we can put it in the body or both.
1:32 So actually I'm going to put it 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.
1:42 But we're going to see if we want to see this logger if this session.get.active user is really getting just the email address of whoever is creating this app script which in our case is not.
1:52 It's going to be us. Once we authorize it, uh it will game back with this Android better sheet. Perfect. It is exactly me.
2:01 This session.get.active user is getting our email address. But we do have an issue with get random quote. I think we're getting.
2:10 I think we need to string. I think. See if this might be too much. Shh. Let's try to run it again.
2:30 Oh actually I think the issue is we need to string the .2.2 string. Thanks watching. I think that's the issue here.
2:46 Or actually we just need get email. We don't need to string. Sorry. That was weird. But now we should just get email and if we run it we shouldn't get that.
2:56 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 uh body is the quote.
3:06 It's actually a different quote in this case. Umm so what we can do is change the subject to, Today's quote.
3:15 We can even add new date to make it a different, absolutely different subject each and every time. We're gonna save that and run it.
3:26 And here we see this uhh. Umm, uhh, formatted date is here. So we can always format this date in a nicer way.
3:34 We're gonna wrap it with utilities.formatDate. We're just gonna give it a format here we want month month. Uhh, actually we're gonna one day day mm year.
3:48 And we need to end the parentheses here. And let's see if that works again. I think we need to use GMT here.
4:04 And maybe this. So now let's see if this works we'll save it. Make sure it's saved. This orange button going away.
4:13 We'll run it and should have an email. Perfect. Our date is formatted well and we only have one quote here.
4:20 Perfect. We're getting a random quote emailed to us. But now how do we do this every day? Email daily is only gonna run when we click run function.
4:28 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.
4:35 And we're gonna choose which function to run. In our case it's gonna be emailed daily. And the event source instead of from spreadsheet we're gonna use time driven.
4:43 We want to do it every day so we'll use day timer and we'll set a time period. In our case we wanted before we start work so something around 5am to 6am.
4:54 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.
5:03 So we'll hit say leave and now I'll get an email every day uh giving me that motivational quote a random one every day uh until I turn off this trigger.
5:16 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 better sheets if you're not on better sheets and watching this go join bettersheets.co and get the sheet and the script all together everything all at once.