I\'m trying to import an xlsx file from a Gmail Attachment to Google Drive (as Google Sheet) using Google Apps Script. I\'ve tried using the Advanced Drive API in GAS, but doing
These
parents: [{id: folderId}],
mimeType: MimeType.GOOGLE_SHEETS
refer to the input file. See docs here. You should skip these.
This snippet worked for me with Google Drive API v2:
function abc() {
var mail = GmailApp.search("SEARCH_TERM")[0];
var msg = mail.getMessages()[0];
var blob = msg.getAttachments()[0];
var file = {
title: 'Converted Spreadsheet'
};
Drive.Files.insert(file, blob, {convert: true});
}