CCCPaste

Google Sheet Sending Emails

function sendEmails() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  const data = sheet.getDataRange().getValues();
  
  for (let i = 0; i < data.length; i++) {
    const row = data[i];
    const email = row[0];
    const username = row[1];
    const password = row[2];

    if (email) {
      const subject = "ICPC Minya — Creativa Wi-Fi Credentials";

      const htmlMessage = `
        

Dear Participant,

Welcome to the ICPC Minya session at Creativa Hub!

Here are your personal Wi-Fi credentials:

  • Username: ${username}
  • Password: ${password}

⚠️ Please note:

  • Do not share your credentials with anyone.
  • Do not use hotspot or share your connection.
  • Connect only on the device you’ll be using during the session.

Best regards,
ICPC Minya Team

`; MailApp.sendEmail({ to: email, subject: subject, htmlBody: htmlMessage }); } } }