![](/img/trans.png)
[英]How to send an email with a formatted table from google sheet using gs?
[英]Send Email from Google sheet as a table without using sheets convertor
請檢查下面的電子表格:電子表格
https://docs.google.com/spreadsheets/d/1QFPO4bQfYPM4rRJ_6PYxUrYsFgVeUFx89_nZ1mNaLew/edit#gid=0
由於我在這里看到的帖子,我目前使用的腳本運行良好。 我只是想以更好的方式發送它。 我已經檢查過其他帖子,我什至看到了 SheetConverter,但對我來說太復雜了。
當前結果: https : //drive.google.com/file/d/1-OQqnsRwIJaoXOnYZEtPxHy6r3buB8H7/view?usp=sharing
請檢查圖像以獲得所需的結果。 謝謝! https://drive.google.com/file/d/1p7cJBTyaZ1ZqI5Jv5WWOGg6_Q-JegfHj/view?usp=sharing
您可以創建一個 html 表,如下所示:
function sendEmail(data){
MailApp.sendEmail({
to: "example@mail.com",
subject: "Example",
htmlBody:"<html><body>" + createTable(data)+ "</body></html>"});
}
function createTable(data){
var cells = [];
var table = "<html><body><br><table border=1><tr><th>Start Date</th><th>End Date</th><th>Leave dates</th><th>Status</th></tr>";
for (var i = 0; i < data.length; i++){
cells = data[i].toString().split(",");
table = table + "<tr></tr>";
for (var u = 0; u < cells.length; u++){
table = table + "<td>"+ cells[u] +"</td>";
}
}
table=table+"</table></body></html>";
return table;
}
假設您已經擁有二維數組中的數據(行和列值)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.