Possible Duplicate:
Google apps script to email google spreadsheet excel version
I looked everywhere for this but cannot get it to work. I am sending an email with an attachment in google app script. The document is a google spreadsheet. It currently sends as a pdf, however, I would like it to send as a xls. When I run the below code, I get "Unsupported Conversion requested". How can I send it as an xls?
function practiceMail() {
var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveRange();
var file = DocsList.getFileById(docID);
var attachment = file.getAs('application/vnd.ms-excel');
var myFile = [file];
MailApp.sendEmail(email, subject, body, {attachments:myFile, mimetype:application/vnd.ms- excel });
}
Please see this question for an explanation. In short, the answer is no. You cannot do this. However, there is an open issue which you can star to request this feature.
Or use the old google docs API https://developers.google.com/google-apps/documents-list/#uploading_a_new_document_or_file_with_both_metadata_and_content