I'm a beginner in using app script and I'm only copying samples at the moment. I'm hoping somebody can help me with the script below. It is meant to fetch an excel file from my Gmail and copy it to a Google sheet. I saw this script from one of the questions here, but can't make it work. Google sheet file is here: https://docs.google.com/spreadsheets/d/1rED5zphZKp7JIK9qaTpHLKBSMsSiLAvhBAXc6Tn0zqI/edit#gid=301517543
Script:
function getRawData() {
var threads = GmailApp.search('subject:myRentokil Report Delivery: Canpac | Pest Activity');
var message = threads[0].getMessages()[0];
var attachment = message.getAttachments()[0];
var xlsxBlob = attachment[0]; // Is supposes that attachment[0] is the blob of xlsx file.
var convertedSpreadsheetId = Drive.Files.insert({mimeType: MimeType.GOOGLE_SHEETS}, xlsxBlob).id;
var sheet = SpreadsheetApp.openById(convertedSpreadsheetId).getSheets()[0]; // There is the data in 1st tab.
var data = sheet.getDataRange().getValues();
Drive.Files.remove(convertedSpreadsheetId); // Remove the converted file.
var sheet = SpreadsheetApp.openById("1rED5zphZKp7JIK9qaTpHLKBSMsSiLAvhBAXc6Tn0zqI").getSheetByName("RawData");
sheet.clearContents();
var range = sheet.getRange(1, 1, data.length, data[0].length);range.setValues(data);
}