[英]Apps Script - Sending email that contain the "Execution log" to the person who runs the script once it's completed
嘗試這個:
function timeAndDate(){
now = new Date();
var firstDayPrevMonth = new Date(now.getFullYear(), now.getMonth()- 1,1);
var firstUnix = Math.floor(new Date(firstDayPrevMonth).getTime()/1000);
var lastDayPrevMonth = new Date(now.getFullYear(), now.getMonth(),1);
var lastUnix = Math.floor(new Date(lastDayPrevMonth).getTime()/1000);
Logger.log('Starting Date:',firstDayPrevMonth,'- Unix Timestamp format:',firstUnix);
Logger.log('Ending Date:',lastDayPrevMonth,'- Unix Timestamp format:',lastUnix);
var body = Logger.getLog();
var recipient = Session.getActiveUser().getEmail();
MailApp.sendEmail(recipient,'App script logs',body);
}
在使用Logger class
記錄執行時使用getLog()
允許您跟蹤執行,然后使用簡單的代碼您可以使用MailApp.sendEmail
方法將其 email 給自己。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.