This is a script to send e-mail with a xlsx file converted from spreadsheet as an attachment file. Access token is necessary to use this script.
function excelSender() {
var accesstoken = "[your accesstoken]";
var sheetID = "[sheet id]";
var xlsxName = "[output xlsx file name]"
var params = {
"headers" : {Authorization: "Bearer " + accesstoken},
"muteHttpExceptions" : true
};
var dUrl = "https://www.googleapis.com/drive/v3/files/" + sheetID + "/export?mimeType=application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
var xlsxlFile = UrlFetchApp.fetch(dUrl, params).getBlob().setName(xlsxName);
MailApp.sendEmail({
to: "[your mail address]",
subject: "sample mail",
body: "sample mail with an excel file",
attachments: [xlsxlFile]
});
}