你不知道这最终解决了我是多么令人难以置信。感谢@Sirik 一百万次坚持使用它并编写代码并帮助我调试它。它完全按照我的意愿去做,它只是世界上最酷的事情,让它完全按照我的意愿去做。
为了后代或任何其他可能想做与我正在做的事情类似的事情的人,这里是确切的代码,所有代码都经过平滑处理,如已实现。你会看到我在最后添加了一些额外的位,以便通过电子邮件将日志发送给我,并给我一个对话框,确认脚本已经运行(我不喜欢单击按钮而不是看到的那种感觉有事发生)。
function Export_Groups_List() {
var options = ['1 & 2 Year Olds\' Playgroup','3 & 4 Year Olds\' Playgroup','Babies\' Playgroup','Book Club','Couples Night Out','Directory','Girls Night Out','Helping Hands','Membership','Newsletter','Serving Sewickley','Treasurer'];
var GROUPS_COL = 5; //This is column 5
var COLG = 6; //Column G
var EMAIL_COL = 23; //Column X
var emailList = ['', '', '', '', '', '', '', '', '', '', '', ''] //12 blanks
var data = SpreadsheetApp.openById('___').getSheetByName('Master').getDataRange().getValues();
for (var i = 1; i < data.length ; i++){
for( var j = 0 ; j < options.length ; j++){
if (data[i][GROUPS_COL].indexOf(options[j]) != -1 &&
data[i][COLG] != 'Yes') {
if (emailList[j] != ''){
emailList[j] += ', ' ;
}
emailList[j] += data[i][EMAIL_COL];
}
}
}
for ( var i = 0 ; i < 12; i ++){
Logger.log(options[i] + ': ' + emailList[i])
}
MailApp.sendEmail("matt@twodoebs.com", "Groups Export", Logger.getLog() + " \n\n" +
"At your request, you've been added to this Sewickley Newcomers & Neighbors Google Group." + "\n\n" +
"Using Google Groups allows us to always have up to date e-mail lists, make sure that people don't get bombarded with messages they don't want, and facilitate smooth communication between our members. If you have any questions about how to use the Google Groups service with your Newcomers & Neighbors membership, please send an e-mail to SewickleyNAN@gmail.com." + "\n\n" +
"Thank you and thanks for your participation!") ;
Browser.msgBox("OK. Check your e-mail for the export list. doebtown rocks the house!")
}