Last active
January 27, 2018 18:14
-
-
Save DimuDesigns/10fc19f9fee2e2f8d64aca5c37431abe to your computer and use it in GitHub Desktop.
Apps Script PDF Export & Email
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var spreadsheetId = "SPREADSHEET_ID", | |
sheetID = "SHEET_ID", | |
respondentEmail = "RESPONDENT_EMAIL"; | |
var response = UrlFetchApp.fetch( | |
"https://docs.google.com/spreadsheets/d/" + spreadsheetId + "/export?" + | |
"format=pdf" + | |
"&size=2" + | |
"&fzr=true" + | |
"&portrait=false" + // you can change this to true for portrait mode | |
"&fitw=true" + | |
"&gid=" + sheetID + | |
"&gridlines=false" + | |
"&printtitle=false" + | |
"&sheetnames=false" + | |
"&attachment=true" | |
); | |
var pdf = response.getAs('application/pdf'); | |
pdf.setName("your_file_name.pdf"); | |
MailApp.sendEmail( | |
{ | |
"to":respondentEmail, | |
"subject":"Subject text", | |
"htmlBody":"Body text", | |
"attachments":[pdf] | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment