My code below for generate PDF attachment is working fine but they send all data in the spreadsheet.
Anyone can help to send only the specify spreadsheet like my code only sheet"Email" in stead of All sheets ? Thank you
function SendEmail() {
try {
var ss = SpreadsheetApp.getActive();
var url = "https://docs.google.com/feeds/download/spreadsheets/Export?key=" + ss.getId() + "&exportFormat=pdf";
var params = {
method : "get",
headers : {"Authorization": "Bearer " + ScriptApp.getOAuthToken()},
muteHttpExceptions: true
};
var blob = UrlFetchApp.fetch(url, params).getBlob();
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Email')
var subjectrange = sheet.getRange("A20");
var subjectdata = subjectrange.getValues();
var emailranges=sheet.getRange('E14');
var emaildata=emailranges.getValue();
var username=ss.getSheetId();
blob.setName(ss.getName()+ ".pdf");
var confirm = Browser.msgBox('Send Email Confirmation','Are you sure you want to send this mail for booking request ?', Browser.Buttons.OK_CANCEL);
if(confirm=='ok') {
MailApp.sendEmail(emaildata, subjectdata, " Attachment file is: \n" +subjectdata+ "- \n Kindly reply your booking to this email . \n Thank you - ADS Co., Ltd", {attachments: [blob]}) };} catch (f) {Logger.log(f.toString());
}
}