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. 谷歌應用程序腳本發送PDF格式的郵件
- 2. 如何使用谷歌應用程序腳本和谷歌表格數據一行發送HTML電子郵件
- 3. 谷歌應用腳本 - 自動更新Google電子表格中的單元格
- 4. 用谷歌應用程序腳本發送完整格式的郵件
- 5. Google應用腳本從個人郵件發送表格郵件
- 6. 通過谷歌應用腳本發佈
- 7. 谷歌應用腳本邊欄不顯示Chrome中的內容
- 8. 谷歌應用程序腳本中的HTML內容
- 9. 發送來自谷歌應用腳本的聊天消息
- 10. 谷歌Apps腳本發送電子表格PDF
- 11. 在Google電子表格中使用Google腳本發送短信
- 12. 谷歌Chrome內容腳本中的jQuery?
- 13. 如何使用谷歌應用程序腳本打開查看谷歌表格
- 14. IE跨域jSONP谷歌應用腳本內容服務
- 15. 使用谷歌腳本通過谷歌表單發送電子郵件收集
- 16. 谷歌應用程序腳本電子表格格式錯誤
- 17. 綁定獨立的谷歌應用程序腳本谷歌表
- 18. 圖表在應用程序腳本谷歌電子表格
- 19. 谷歌應用程序腳本的電子表格
- 20. 谷歌應用服務的電子表格返回URL腳本
- 21. 發送郵件谷歌腳本
- 22. 谷歌腳本發送電子郵件
- 23. 從谷歌驅動器發送多個附件與Google腳本
- 24. 按谷歌腳本在Google表格中每日價格排序
- 25. 谷歌應用程序腳本 - 繪圖作爲按鈕打開谷歌表格
- 26. 谷歌電子表格與谷歌應用程序腳本查詢
- 27. 谷歌文檔/應用程序API:電子表格(Google表格)
- 28. 谷歌表格應用程序腳本自動重定向URL
- 29. 谷歌應用程序腳本搜索電子表格
- 30. 谷歌應用程序腳本表格不能正常工作
https://mailparser.io/blog/send-emails-from-google-spreadsheet/ –