You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Handle what to do if students are checked vs. no students are checked
77
+
// If students are checked, send the message
78
+
if(bccEmails.length>0){
79
+
// Prompt for the email message
80
+
varresponse=ui.prompt('Draft Message','Type in the basic message you would like to send (you may edit or add more later in Gmail):',ui.ButtonSet.OK_CANCEL);
81
+
varemailBody=response.getResponseText();
82
+
varbatchCount;// The number of emails we will send (we need to break it up because there is a limit set by Google as maxEmails)
83
+
varemailCount;// The number of emails in the array
84
+
varmaxEmails=50;// The max amount of emails allowed in a message (could be changed by Google)
85
+
86
+
// If user is ready to send the message.
87
+
if(response.getSelectedButton()==ui.Button.OK){
88
+
// Count the number of emails in the array
89
+
emailCount=bccEmails.length;
90
+
91
+
// Determine how many messages to send (batches of maxEmails - the limit Google will allow)
// If there are more than 50 email recipients then send a special message
100
+
if(batchCount>1){
101
+
messageCountText="\nGoogle has a limit of "+maxEmails+" email addresses per message so "+batchCount+" drafts have been created.\nThis is draft "+messageNum+" of "+batchCount+"."
102
+
}
103
+
104
+
varfullMessage="------------DELETE BEFORE SENDING------------"+messageCountText+"\n\nMESSAGE BEING SENT FOR:\n"+studentNames.join('\n')+"\n\n------------DELETE BEFORE SENDING------------\n\n\n"+emailBody;
// Populate the next column with the message that was sent
111
+
for(vari=1;i<data.length;i++){
112
+
varsendEmail=data[i][0];// Get status of checkbox in the first column
113
+
114
+
if(sendEmail==true){
115
+
varcell=sheet.getRange(i+1,messageColumnIndex+1);
116
+
cell.setValue(emailBody);// Paste the email message sent
117
+
118
+
// Timestamp
119
+
varcell=sheet.getRange(i+1,doneColumnIndex+1);// This will create a cell object based on the row/column coordinates for the status cell
120
+
cell.setValue(currentDate);// Set status message for parents already emailed
121
+
}
122
+
}
123
+
Logger.log('Draft created with BCC: '+bccEmails.join(', '));
124
+
SpreadsheetApp.getUi().alert('GMAIL DRAFT CREATED!\n\nCheck your Deltalearns Gmail DRAFTS folder\nto complete and send your message.\n\nBY: JONATHAN KUNG');
125
+
}
126
+
// If user is not ready to send the message.
127
+
else{
128
+
ui.alert('Cancelled.');
129
+
Logger.log('User cancelled the message send.')
130
+
}
131
+
resetCheckboxes();
132
+
}
133
+
else{// If no students are checked, send alert and don't send anything.
0 commit comments