Daily Messages
This is a personal project I had. At some point I learned that every mobile phone number comes with an email address that no one knows about. Instead of texting someone you can send an email to that address and it will show up as a text on the person’s phone from your email address.
Every mobile phone provider has a different system for that email address so you have to do some research, but I found the email for the top 5 or so providers. Now I can send emails as texts, but for what purpose?
Birthday Texts:
Everyone sends a happy birthday text to friends and family on their birthday. And sometimes you want to be the first person, but you have to remember and also wake up early enough to do it. Well now that I know how to send texts from my email, and I also know how to send emails from Google Spreadsheets… I just need a sheet with dates and messages. So I made a list of all the birthdays in my family, a special message to each person, and then wrote the script to send the email. I just had to decided when every day the script should run, so I decided 7 AM was about right. It was, for me in Utah, but a little early for my sister’s in Las Vegas… But it became a family joke and was fun.
Daily Messages:
My wife once wrote me messages on index cards, one for every day of the year. I would open it up at work when I worked in an office and read them every day. It was super cute, thoughtful, and a lot of work. So I tried to do the same for her, thru text messages. It would run every day in middle of the day while I was at work. It would send the message I had typed out beforehand. I just had to make sure there were enough messages in there before their dates so they would keep sending.
Google App Script for Birthdays
Here's a little snippet of the script I wrote for the birthday texts:
var ss = SpreadsheetApp.getActive();
var births = ss.getSheetByName("Birthdays");
function birthdays() {
// Dates and formats
const dateFormat = "MM/dd";
var dateToday = Utilities.formatDate(
new Date(),
Session.getScriptTimeZone(),
"MM/dd",
);
var lastRow = births.getLastRow();
// The magic loop through all rows
for (var i = 2; i <= lastRow; ++i) {
// Variables that change, can't be set as let in Google App Script
var targetDate = new Date(births.getRange(i, 7).getValue());
var nickName = births.getRange(i, 3).getValue();
var smsText = births.getRange(i, 8).getValue();
var birthdayEmail = births.getRange(i, 9).getValue();
var sentVerificationCell = births.getRange(i, 12);
var isMessageBlank = births.getRange(i, 8).isBlank();
const myCarrierPhoneEmail = "AddYourCarrierEmailHere";
const timeZone = Session.getScriptTimeZone();
const timeStamp = Utilities.formatDate(
new Date(),
Session.getScriptTimeZone(),
"MM/dd/yyyy hh:mm",
);
// Put the variables to use, if the message isn't blank and the date is their birthday
if (
!isMessageBlank &&
dateToday == Utilities.formatDate(targetDate, timeZone, dateFormat)
) {
// Send the email text to them and a reminder to myself
MailApp.sendEmail(birthdayEmail, "", smsText);
MailApp.sendEmail(
myCarrierPhoneEmail,
"",
"You just text " + nickName + " '" + smsText + "'.",
);
// Save a timestamp to the last cell of their row so I know it sent as well.
sentVerificationCell.setValue("Sent " + timeStamp);
}
}
}