Skip to content

Instantly share code, notes, and snippets.

@seoutopico
Last active July 8, 2022 07:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seoutopico/ecffdec37ccc92133588f1760ef517d1 to your computer and use it in GitHub Desktop.
Save seoutopico/ecffdec37ccc92133588f1760ef517d1 to your computer and use it in GitHub Desktop.
function sendEmail() {
let fechahoy = new Date().toLocaleDateString()
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("comparativa");
var data = ss.getRange ("A1:D5").getValues();
var message = getTable(data);
var mensaje = {
to: "destino",
subject : "Estas SEO" + fechahoy,
htmlBody: message,
name: "Aina-Lluna Taylor Barceló - SEO"
}
MailApp.sendEmail(mensaje);
}
function getTable(data) {
var result = ["<table'>"];
var ll = data[0].length;
var row = 0;
for(var i = 0, l = data.length; i < l; i++) {
row = data[i];
result.push("<tr>");
for(var ii = 0; ii < ll; ii++){
result.push('<td>' + row[ii] + '</td>');
}
result.push("</tr>");
}
result.push("</table>");
return( result.join('\n'));
}
@seoutopico
Copy link
Author

Script que te permite enviar mails desde un rango de datos en una tabla de html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment