Send Automatic Birthday Reminders using Google Sheets & Google Apps Script
This tutorial shows you how to use Google Sheets and Apps Script to send automatic email reminders for birthdays — be it for friends, family, or office colleagues. A scheduled trigger will run daily and send beautiful HTML emails when a birthday matches today's date!
๐ Step 1: Setup Google Sheet
Create a new Google Sheet and name it Birthday Reminder Tracker. Use the following structure:
Column | Details |
---|---|
Sr No | 1 |
Name | Jane Doe |
Birthday | 1995-06-28 |
janedoe@email.com | |
Reminder Time (HH:MM) | 09:00 |
Last Sent | (empty) |
Last Sent: This column will be updated automatically to avoid duplicate mails.
๐ป Step 2: Add Google Apps Script
- Click Extensions → Apps Script
- Clear any default code
- Paste the script below ๐
function sendBirthdayReminders() {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Birthdays");
const data = sheet.getDataRange().getValues();
const today = new Date();
const currentTime = Utilities.formatDate(today, Session.getScriptTimeZone(), "HH:mm");
const todayStr = Utilities.formatDate(today, Session.getScriptTimeZone(), "yyyy-MM-dd");
for (let i = 1; i < data.length; i++) {
const name = data[i][1]; // Column B
const dob = new Date(data[i][2]); // Column C
const email = data[i][3]; // Column D
const reminderTime = data[i][4]; // Column E
const lastSent = data[i][5]; // Column F
const birthDay = dob.getDate();
const birthMonth = dob.getMonth();
Logger.log(`Row ${i + 1} - Name: ${name}, Birthday: ${dob}, Email: ${email}`);
Logger.log(`Today: ${todayStr}, ReminderTime: ${reminderTime}, CurrentTime: ${currentTime}, LastSent: ${lastSent}`);
if (today.getDate() === birthDay && today.getMonth() === birthMonth) {
Logger.log(`${name}'s birthday is today.`);
if (currentTime === reminderTime && lastSent !== todayStr) {
Logger.log(`Time matched & not already sent. Sending email to ${email}`);
const subject = "๐ Happy Birthday: " + name;
const message =`
๐ Happy Birthday, ${name}!
We just wanted to let you know that today is a special day — it's your birthday! ๐
Wishing you a day filled with love, laughter, and wonderful memories ๐ฅณ
Warm wishes,
๐ Your Awesome Reminder System
`;
MailApp.sendEmail({
to: email,
subject: subject,
htmlBody: message
});
sheet.getRange(i + 1, 6).setValue(todayStr); // Update Last Sent
} else {
Logger.log(`Not sending: Either time doesn't match or already sent.`);
}
} else {
Logger.log(`${name}'s birthday is not today.`);
}
}
}
⏰ Step 3: Set a Daily Trigger
- Go to Apps Script → Triggers (⏰ icon on left)
- Click + Add Trigger
- Choose
sendBirthdayReminders
function - Set event type as Time-driven
- Choose "Every hour"
๐จ Sample Email Preview
๐ Happy Birthday Jane Doe!
We just wanted to let you know that today is a special day — it's your birthday! ๐
Wishing you a day filled with love, laughter, and wonderful memories ๐ฅณ
Warm wishes,
๐ Your Awesome Reminder System
๐ Final Words
This system can be a great personal assistant — reminding you of birthdays of colleagues, clients, friends or family.
Next up, we’ll add Google Calendar integration and Slack/WhatsApp alerts. Stay tuned!
Found this useful? Share it with others and explore more automation tutorials on our blog!
๐บ Watch Tutorial: Scripted Success Master on YouTube
๐ Visit Blog: scriptedsuccessmaster.blogspot.com
Comments
Post a Comment