Email a Custom Sheets as PDF in Attachment
How to use it
- Sheets you want to print :
you can add more inside the array
var wantedSheets=[' Sheet1','Sheet2','Sheet3'.....];
- Print Options :
- Email parameters :
Seperate each email with comma :
MailApp.sendEmail('pace3man@gmail.com,medrx82@gmail.com', 'Title', 'Body',...
The Code
Please Comment and help us with share !
how can i send Pivot table on mail body and sheet-1 as attachment?
ReplyDeleteThe Above Question Is same here....
DeleteHave you got an answer from anyone????
Great Code! Super easy to follow!
ReplyDeleteWas the best code.
ReplyDeleteADEL! You the MAN! Thank you, works perfect. A few question... how can you set page margins and page height/width?
ReplyDeleteHi, I think this solution is a little simpler: (But thank you for your kode)
ReplyDelete//Get Active Spreadsheet
var spreadSheet=SpreadsheetApp.getActiveSpreadsheet();
//Get Sheet to print of the spreadsheets
var sheets=spreadSheet.getSheets();
var mySheet = spreadSheet.getSheetByName("PrintSheet");
var sheetID = mySheet.getSheetId();
//Export URL with Parameters
var spreadSheetId = spreadSheet.getId();
var URL = "https://docs.google.com/spreadsheets/d/"+spreadSheetId+"/export"+
"?format=pdf&"+
"size=7&"+
"fzr=false&"+
"portrait=true&"+
"fitw=true&"+
"gridlines=false&"+
"printtitle=false&"+
"sheetnames=false&"+
"pagenum=UNDEFINED&"+
"attachment=true&"+
"gid="+sheetID;
//the HTTP method for the request: get and headers : authorization : Bearer tokens to access OAuth 2.0-protected resources
var params = {method:"GET",headers:{"authorization":"Bearer "+ ScriptApp.getOAuthToken()}};
its a great code!
ReplyDeleteCan anyone help, I'm fairly new to script but have fumble my way this far.
ReplyDeleteI have a spreadsheet that has 9 pages as standard, occasionally an additional 3-4 get inserted depending on the use of the spreadsheet.
I need to be able to create a PDF of all pages except page 1, and 2x hidden pages (which contain reference tables for vlookups).
The PDF format needs to be specific for the data to sit on the page properly.
I don't need to email it but instead just save it to another drive folder.
Thanks for any help in advance. 👍
I want to email specific range.
ReplyDeleteme also want to send specific range by range name option or by writing specific range
ReplyDeleteHey Can i export a particular range of cells the same way? If yes what code do i have to add and where please??
ReplyDeletei want to change page setting to legal how can i do that in thisapp script
ReplyDeletecan i use it for commercial purpose
ReplyDeleteyes
Delete