I need to send a google spreadsheet file as an .xlsx by email attachment. I know this can be done using UrlFetchApp, but my organization is blocking this service for security reasons, so I can only use DriveApp and MailApp.
My Code:
function testsendxlsx() {
var spreadsheetId = "id_here"
var file = DriveApp.getFileById(spreadsheetId);
var blob = file.getAs(MimeType.MICROSOFT_EXCEL);
var fileName = "testing" + '.xlsx';
var receipient = "email_here"
var subject = "testing .xlsx"
var emailbody = "something"
MailApp.sendEmail(receipient, subject, emailbody, {attachments: blob});
}
I get this error:
Converting from application/vnd.google-apps.spreadsheet to application/vnd.openxmlformats-officedocument.spreadsheetml.sheet is not supported. (line 6, file "Code")
Any ideas how this could be done?