Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Send emails to people for secret santa. Assumes data is already shuffled.
- */
- function sendEmails() {
- var sheet = SpreadsheetApp.getActiveSheet();
- // B = name of person
- // C = email of person
- // D = name of assigned person
- // F = things they like
- // G = things they don't like
- var startRow = 2; // first row of data to process
- var numRows = 29; // number of rows to process (last row - start row)
- // fetch the range of cells B2:G30
- var dataRange = sheet.getRange(startRow, 2, numRows, 7)
- // fetch values for each row in the Range.
- var data = dataRange.getValues();
- for (i in data) {
- var row = data[i];
- var name = row[0]; // B (0 because we didn't include A)
- var email = row[1]; // C
- var assignedName = row[2]; // D
- var like = row[4]; // F
- var dislike = row[5]; // G
- var subject = "Secret Santa assignment!";
- var message = "You've been assigned " + assignedName +
- ".\n\nThey like:\n"+ like +
- "\n\nAnd dislike:\n"+ dislike +
- "\n\nGifts tend to be ~$15 but feel free to go wild! " +
- "Please include 3 hints as to who you are (in the packaging or note or whatnot). " +
- "Gifts will be exchanged during the Winter Banquet (12/9)." +
- "\n\nHave fun!\n <3 Your social chairs";
- MailApp.sendEmail(email, subject, message);
- Logger.log("Sent email to " + name);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement