Send the entire Google Sheets as an attachment to the specified email address for backup

888u

Last update at :2024-07-10,Edit by888u

With the scheduled execution of scripts and Google Scripts, the entire Google Sheets can be sent as an attachment to a designated email address for backup at certain intervals.

//////////////

function onOpen() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var menuEntries = [ {name: “Send Email”, functionName: “backupGoogleSpreadsheetAsExcel”}]; ss.addMenu("Scripts", menuEntries); };

function backupGoogleSpreadsheetAsExcel(){

try {

var ss = SpreadsheetApp.getActive();

var url = “https://docs.google.com/feeds/download/spreadsheets/Export?key=” + ss.getId() + “&exportFormat=xlsx”;

var params = { method: "get", headers: {“Authorization”: “Bearer ” + ScriptApp.getOAuthToken()}, muteHttpExceptions: true };

var blob = UrlFetchApp.fetch(url, params).getBlob();

blob.setName(ss.getName() + “.xlsx”);

MailApp.sendEmail("Receive Email", "Google Sheet to Excel", "The XLSX file is attached", {attachments: [blob]});

} catch (f) { Logger.log(f.toString()); } }

////////////////

Reprinted from: https://www.hostloc.com/thread-541812-1-1.html

Recommended site searches: cloud server rental, US host purchasing, domain name registration query, dynamic IP dialer, asp.net space, website space registration-free, 100m free space Shandong registration, free asp space, same IP site query, < /p>

Send the entire Google Sheets as an attachment to the specified email address for backup

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码