Google sheet to PDF Email getActiveSheet()

I am looking for a convert current google sheet into PDF and send mail ActiveSheet.

: This code looping all sheet into pdf and emailing me I want mail only active tab.

//this code working fine but looping all sheet
function sendReport() {

  var message = {
    to: "[email protected]",
    subject: "Monthly sales report",
    body: "Hi team,nnPlease find the monthly report attached.nnThank you,nBob",
    name: "Bob",
    setName: "New",
    attachments: [SpreadsheetApp.getActiveSpreadsheet().getAs(MimeType.PDF).setName("New Report")]
  }
  MailApp.sendEmail(message);
}


  // this method is not working  
  // var ss = SpreadsheetApp.getActiveSpreadsheet();
  // var singleSheet = ss.getActiveSheet()

Answer

See if this helps

const sendReport = () => {
  const spreadsheet = SpreadsheetApp.getActive();
  const activeSheet = spreadsheet.getActiveSheet();
  const sheets = spreadsheet.getSheets();
  
  //hide all sheets except the active sheet
  sheets.forEach(sh => {
    if (sh.getName() !== activeSheet.getName()) sh.hideSheet()
  })

  const message = {
    to: "[email protected]",
    subject: "Monthly sales report",
    body: "Hi team,nnPlease find the monthly report attached.nnThank you,nBob",
    name: "Bob",
    setName: "New",
    attachments: [spreadsheet.getAs(MimeType.PDF).setName('New Report')]
  }

  MailApp.sendEmail(message);

  //unhide all sheets
  sheets.forEach(s => s.showSheet());
}