Recipe
Email a Google Sheet tab as a PDF on a schedule
Exports one tab to PDF, names it with the date, and emails it to the address you set. Add a weekly trigger and the report arrives by itself.
Set it up
- Paste the script, set sheetName and to in SP, and save.
- Run emailSheetPdf once and approve the prompts (it asks for external request access).
- Triggers > Add trigger > emailSheetPdf > Time-driven > Week timer.
The script
/**
* Email one sheet tab as a PDF on a schedule.
* Add a time-driven trigger (weekly or daily) for emailSheetPdf.
*/
var SP = { sheetName: 'Report', to: 'you@example.com', subject: 'Weekly report', wide: true };
function emailSheetPdf() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName(SP.sheetName);
var url = 'https://docs.google.com/spreadsheets/d/' + ss.getId() + '/export?format=pdf'
+ '&gid=' + sheet.getSheetId()
+ '&portrait=' + (SP.wide ? 'false' : 'true')
+ '&fitw=true';
var response = UrlFetchApp.fetch(url, { headers: { Authorization: 'Bearer ' + ScriptApp.getOAuthToken() }, muteHttpExceptions: true });
if (response.getResponseCode() !== 200) throw new Error('PDF export failed: HTTP ' + response.getResponseCode());
var day = Utilities.formatDate(new Date(), Session.getScriptTimeZone(), 'yyyy-MM-dd');
var pdf = response.getBlob().setName(SP.sheetName + ' ' + day + '.pdf');
MailApp.sendEmail({ to: SP.to, subject: SP.subject + ' ' + day, body: 'The report is attached.', attachments: [pdf] });
return 'sent';
}What you should see
| To | Subject | Attachment |
|---|---|---|
| you@example.com | Weekly report 2026-11-14 | Report 2026-11-14.pdf |
The email as it arrives. Sample values, not output from a real account.
Common errors and fixes
- PDF export failed: HTTP 401 or 403
- Re-authorize the script. The account running the trigger must be able to open the sheet.
- The PDF is cut off
- Set wide to true, or reduce the print range.
- Exception: Cannot call SpreadsheetApp.getActiveSpreadsheet from this context
- Use a script bound to the sheet, or open it by ID.
Permissions. Running this script asks you to grant Google permissions for the services listed above, to your own script. TriggerShelf never receives your Google data. See the permissions table. Google will show "Google hasn't verified this app"; that is expected for a script you paste yourself.
TriggerShelf is independent and not affiliated with or endorsed by Google LLC. Google Sheets, Gmail, Google Drive and Apps Script are trademarks of Google LLC. Quota figures come from Google's Apps Script quotas page. Test on a copy first.