automated daily emails from google sheets contacts

I’m working with a Google Sheets document that has a column containing email addresses. I want to automatically send emails to all these contacts once per day at a specific time.

I’m wondering what the best approach would be for this. Can I use Google Apps Script to access the spreadsheet data? I think I need to loop through each row and extract the email addresses, then send messages to each one.

Here’s a basic example of what I’m thinking:

function sendDailyEmails() {
  var sheet = SpreadsheetApp.getActiveSheet();
  var data = sheet.getDataRange().getValues();
  
  for (var i = 1; i < data.length; i++) {
    var recipientEmail = data[i][2]; // assuming email is in column C
    var subject = "Daily Update";
    var message = "Hello! This is your daily notification.";
    
    MailApp.sendEmail(recipientEmail, subject, message);
  }
}

Is this the right direction? How can I set this up to run automatically every day? Any suggestions would be really helpful.

Your code’s a good start. You’re just missing the time trigger to run it automatically each day. Head to Apps Script editor and click the clock icon (Triggers) in the sidebar. Create a new trigger for your sendDailyEmails function - set it to time-driven with day timer for whatever hours work best. I’d add some basic error handling too. Check if the email cell has data before sending, or you’ll get errors on empty rows. If you’ve got lots of recipients, throw in a small delay between sends so you don’t hit rate limits. I’ve used this setup for monthly reports and it’s rock solid once the trigger’s configured right.

The approach looks solid, but I’d make a few tweaks based on my experience with similar automation. First, add validation to skip empty or invalid emails - something like if (!recipientEmail || recipientEmail.indexOf('@') === -1) continue; in your loop. MailApp has daily quotas too (100 emails for regular accounts, 1500 for Workspace), so watch your contact list size. For triggers, go to your Apps Script project, hit Triggers in the left menu, and create a time-based trigger for daily runs at whatever hour works. One thing I learned the hard way - test with a small group first and throw in some console.log() statements to track which emails actually went through.

yeah, that’s basically right, but check your gmail quotas first. i’d add some logging to track what’s happening - maybe write the status back to the sheet? also throw in utilities.sleep(1000) between emails if you’re sending to lots of contacts. for triggers, go to script editor > resources > current project’s triggers (the menu might look different depending on which interface you’re using). works great once you get it set up!