0
A
回答
0
這將紙張發送的XLS到您的電子郵件。讓這個工作,然後設置一個基於時間的觸發器。 - 同時注意這是一張私人表單,在電子郵件發送後立即公開發布,然後重新設置爲私人表單。
function getGoogleSpreadsheetAsExcel(){
try {
var ss = SpreadsheetApp.getActive();
var sheet = DriveApp.getFileById(ss.getId());
// sets sharing to public - to send out email.
sheet.setSharing(DriveApp.Access.ANYONE, DriveApp.Permission.EDIT);
var url = "https://www.googleapis.com/drive/v3/files/" + ss.getId() + "/export?mimeType=application/vnd.openxmlformats-officedocument.spreadsheetml.sheet&key=" + "YOUR_KEY_GOES_HERE";
var blob = UrlFetchApp.fetch(url).getBlob();
Logger.log(url);
blob.setName(ss.getName() + ".xlsx");
var now = new Date();
MailApp.sendEmail("YOUR_EMAIL_ADDRESS_GOES_HERE", "Backup " + now , "Backup " + now , {attachments: [blob]});
} catch (f) {
Logger.log(f.toString());
}
// returns the file back to Private access
sheet.setSharing(DriveApp.Access.PRIVATE, DriveApp.Permission.EDIT);
}
+0
感謝您的建議@OblongMedulla,我應該更清楚 - 它需要在電子郵件的正文中。 –
0
這裏是我的解決方案,到目前爲止,但它不乾淨&很不理想:
function myFunction() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var range = sheet.getRange(2, 1, sheet.getLastRow(), sheet.getLastColumn());
var data = range.getValues();
var body = '';
for(var row in data) {
for(var col in data[row]) {
body += data[row][col] + '\t';
}
}
body += '\n';
}
Logger.log(body);
// MailApp.sendEmail('[email protected]', 'Director Dealings', body);
}
0
您可以檢查此tutorial如何發送電子郵件從一個電子表格。
function sendEmails() {
var sheet = SpreadsheetApp.getActiveSheet();
var startRow = 2; // First row of data to process
var numRows = 2; // Number of rows to process
// Fetch the range of cells A2:B3
var dataRange = sheet.getRange(startRow, 1, numRows, 2)
// Fetch values for each row in the Range.
var data = dataRange.getValues();
for (i in data) {
var row = data[i];
var emailAddress = row[0]; // First column
var message = row[1]; // Second column
var subject = "Sending emails from a Spreadsheet";
MailApp.sendEmail(emailAddress, subject, message);
}
}
您需要使用MailApp.sendEmail()
。請注意,此方法有四個版本
相關問題
- 1. 如何使用谷歌應用程序腳本和谷歌表格數據一行發送HTML電子郵件
- 2. 谷歌應用腳本 - 自動更新Google電子表格中的單元格
- 3. 用谷歌應用程序腳本發送完整格式的郵件
- 4. 谷歌應用腳本邊欄不顯示Chrome中的內容
- 5. 谷歌Chrome內容腳本中的jQuery?
- 6. 在Google電子表格中使用Google腳本發送短信
- 7. 使用谷歌腳本通過谷歌表單發送電子郵件收集
- 8. IE跨域jSONP谷歌應用腳本內容服務
- 9. 綁定獨立的谷歌應用程序腳本谷歌表
- 10. 發送郵件谷歌腳本
- 11. 谷歌應用程序腳本 - 繪圖作爲按鈕打開谷歌表格
- 12. 谷歌電子表格與谷歌應用程序腳本查詢
- 13. 谷歌文檔/應用程序API:電子表格(Google表格)
- 14. 複製谷歌應用程序腳本與表格
- 15. 谷歌應用程序腳本表格不能正常工作
- 16. 谷歌表格應用程序腳本自動重定向URL
- 17. 導出谷歌電子表格,RSS格式使用谷歌Apps腳本
- 18. 使用谷歌應用程序提交對Google表單的回覆腳本
- 19. 谷歌應用程序腳本的Daterangepicker
- 20. 谷歌腳本 - 谷歌表格 - 獲取條目的字符串
- 21. 用的setValue()在谷歌表腳本
- 22. adwords腳本到谷歌電子表格
- 23. 與谷歌腳本和電子表格
- 24. 使用谷歌腳本發送Gmail郵件
- 25. 使用谷歌應用腳本在谷歌大查詢保存表
- 26. 使用谷歌應用程序腳本更新谷歌聯繫標記表
- 27. 谷歌電子表格的腳本觸發器
- 28. 谷歌應用程序腳本公式
- 29. 谷歌應用程序腳本,連勝
- 30. 郵件合併谷歌應用腳本
https://mailparser.io/blog/send-emails-from-google-spreadsheet/ –