👉Google Apps Script
最后更新于
最后更新于
function doPost(e) {
var param = e.parameter ;
var title = '' ;
var body = '' ;
switch (param.Order_Status) {
case "新成立":
title = "新訂單成立" ;
body = "如有現貨,寄貨時間為1~3天內。" ;
break;
case "缺貨中":
title = "品項缺貨中" ;
body = "﹝目前訂單內品項尚有缺貨﹞" ;
break;
case "已完成":
title = "訂單已完成" ;
body = "感謝您本次購買<br>如使用商品符合您的期待<br>歡迎再次回購<br>購物網站:<br>https://jay.twl.ink/" ;
break;
case "取消單":
title = "訂單已取消" ;
body = "取消原因:" + param.Order_Remarks ;
break;
default:
title = "";
break;
}
try {
MailApp.sendEmail({
name: "Jay 管理系統",
to: param.Client_Email,
bcc: "jay@1oe0.com",
replyTo: "jay@1oe0.com",
subject: "小傑的賣場﹝" + title + "﹞",
htmlBody: "<p>" + param.Client_Name + " 您好,訂單資訊如下</p>"+
"<p>訂單編碼:" + param.Orders_ID +
"<br>下單時間:" + param.Time_Create +
"<br>目前狀態:" + param.Order_Status +
"</p><p>" + body + "</p>" +
"<a href=\"https://jay.1oe0.com/Data.php?SID=" + param.Orders_ID + "\" target=\"_blank\"> 點我查看訂單 </a>" +
"<p>此為系統自動發送,請勿直接回覆。</p>"+
"<p>若您對訂單有任何問題,歡迎透過客服信箱:<br>jay@1oe0.com<br>或者聯絡本人Instagram:<br>https://www.instagram.com/_____28.o7_prince/</p>",
});
} catch(ex) {
console.error(ex);
}
return ContentService.createTextOutput("傳送成功");
}
function emailQuotaRemaining() {
var emailQuotaRemaining = MailApp.getRemainingDailyQuota();
Logger.log("Remaining email quota: " + emailQuotaRemaining);
}
創建一個表單 https://forms.new
點選『回覆』連結一個試算表
點選『工具』選擇『指令碼編輯器』
貼上程式碼
圖片程式碼僅供參考,請以下方最新程式碼為準。
function onSubmit(datas) {
// 取得提交的值
var Data = datas.namedValues;
// 要傳送的訊息
var Message = 'Google表單收到新提交\\n';
// 整理訊息
for(var Key in Data) {
Message += Key + ':' + Data[Key] + '\\n';
}
// 發送訊息
var List = JSON.parse(UrlFetchApp.fetch('<https://org.1oe0.com/Api/Notify?T=46963e88437560cbe463b1fdc2d9543a>'));
for (var Key in List) {
try {
UrlFetchApp.fetch('<https://notify-api.line.me/api/notify>', {
'headers': {
'Authorization': 'Bearer ' + List[Key],
},
'method': 'post',
'payload': {
'message': Message
}
})
} catch(ex) {
console.error(List[Key] , ex);
}
}
}
切換至『觸發條件』
新增一個觸發條件『活動類型』選擇『提交表單時』