Created
April 11, 2012 14:17
-
-
Save fabiorecife/2359573 to your computer and use it in GitHub Desktop.
send mail with google apps script
This file contains hidden or 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 sendMailAvaliacaoFicha() { | |
| var sheet = SpreadsheetApp.getActiveSheet(); | |
| var startRow = 2; // First row of data to process | |
| var numRows = 9; // Number of rows to process | |
| // Fetch the range of cells A2:F10 | |
| var dataRange = sheet.getRange(startRow, 1, numRows, 6) | |
| // Fetch values for each row in the Range. | |
| var data = dataRange.getValues(); | |
| for (i in data) { | |
| var row = data[i]; | |
| var emailAddress = row[1]; // First column | |
| var message = "Bom dia " + row[5] +",<br/>\n"+ | |
| 'Analisamos a sua <strong>avaliação</strong>:<br/>'+'<pre style="font-family: monospace;font-size: 14px;">' + row[2]+"</pre><br/>\n"+ | |
| "Para atender sua avaliação identificamos as seguintes <strong>ações</strong> :\n"+'<pre style="font-family: monospace;font-size: 14px;">' + | |
| row[3]+"</pre><br/>\n"+ | |
| "Estas ações devem atender " + (row[4]*100) + "% de sua avaliação.<br/>" + | |
| "Caso deseje mais alguma informação entrar em contato com <br/><br/>"+ | |
| "Fábio Almeida<br/>" ; // Second column | |
| var subject = "::Resultado da Avaliação da Ficha"; | |
| MailApp.sendEmail(emailAddress, subject, "", { htmlBody:message, bcc: "mymail@example.com" }); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment