[英]Send Email from Google sheet as a table without using sheets convertor
Please check the spreadsheet below: spreadsheet请检查下面的电子表格:电子表格
https://docs.google.com/spreadsheets/d/1QFPO4bQfYPM4rRJ_6PYxUrYsFgVeUFx89_nZ1mNaLew/edit#gid=0 https://docs.google.com/spreadsheets/d/1QFPO4bQfYPM4rRJ_6PYxUrYsFgVeUFx89_nZ1mNaLew/edit#gid=0
The script that I'm currently using is working fine thanks to the posts I've seen here.由于我在这里看到的帖子,我目前使用的脚本运行良好。 I just wanted to send it in a better way.
我只是想以更好的方式发送它。 I've already checked other posts and I even saw the SheetConverter but is too complicated for me.
我已经检查过其他帖子,我什至看到了 SheetConverter,但对我来说太复杂了。
Current Result: https://drive.google.com/file/d/1-OQqnsRwIJaoXOnYZEtPxHy6r3buB8H7/view?usp=sharing当前结果: https : //drive.google.com/file/d/1-OQqnsRwIJaoXOnYZEtPxHy6r3buB8H7/view?usp=sharing
Please check image for the desired result.请检查图像以获得所需的结果。 Thanks!
谢谢! https://drive.google.com/file/d/1p7cJBTyaZ1ZqI5Jv5WWOGg6_Q-JegfHj/view?usp=sharing
https://drive.google.com/file/d/1p7cJBTyaZ1ZqI5Jv5WWOGg6_Q-JegfHj/view?usp=sharing
You can create an html table, like this:您可以创建一个 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;
}
Supposing you already have the data in a 2D array (rows and columns values).假设您已经拥有二维数组中的数据(行和列值)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.