I want to email a specified range from the current active google sheet.There is an error with this code,it says TypeError: SpreadsheetApp.getActiveSpreadsheet(...).getRange(...).getAs is not a function Line 9
function sendReport() {
SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Responses").hideSheet();
SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Form").activate();
var message = {
to: SpreadsheetApp.getActiveSheet().getRange('L2').getValue(),
subject: "Monthly sales report",
body: "Hi team,\n\nPlease find the monthly report attached.\n\nThank you,\nBob",
name: "Bob",
attachments: [SpreadsheetApp.getActiveSpreadsheet().getRange("Form!A5:H25").getAs(MimeType.PDF).setName("Monthly sales report")]
}
MailApp.sendEmail(message);
SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Responses").activate();
}