Last active
June 8, 2016 10:40
-
-
Save cmilfont/648e466ce496373fad9e5438b2f2f3ad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sorteio() { | |
var linhasTotais = SpreadsheetApp.getActiveSheet().getLastRow(); | |
var livro = "\"Casa Do Codigo X\""; | |
var currentSheet = SpreadsheetApp.getActiveSheet(); | |
var vencedor = Math.ceil(Math.random()*linhasTotais); | |
var email = currentSheet.getRange(range("B", vencedor)).getValue(); | |
Browser.msgBox("Sorteio do livro " + livro + " vai para: " + email); | |
//MailApp.sendEmail(email, "Sorteio CEJS!", "Se você está presente no sorteio foi sorteado para ganhar o brinde " + livro + "."); | |
} | |
function range(celula, vencedor) { return celula + vencedor + ":" + celula + vencedor; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function anuncioSorteio() { | |
var linhasTotais = SpreadsheetApp.getActiveSheet().getLastRow(); | |
var patrocinador = "\"Casa Do Codigo ( https://www.casadocodigo.com.br/ ). \""; | |
var currentSheet = SpreadsheetApp.getActiveSheet(); | |
var script = "https://gist.github.com/cmilfont/648e466ce496373fad9e5438b2f2f3ad"; | |
var mensagem = "Sorteio automático agendado, você ganhou um ebook pela " + patrocinador; | |
for(var i = 0; i < 5; i++){ | |
var vencedor = Math.ceil(Math.random()*linhasTotais); | |
var inscrito = currentSheet.getRange(range("B", vencedor)).getValue(); | |
Logger.log(inscrito); | |
MailApp.sendEmail(inscrito, "Sorteio CDC CEJS 2016!", mensagem); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment