You can create an html table, like this:
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).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…