google 有一個apps script的服務,可以結合表單 。
function sendEmailOnNewEntry(e) {
var sheet = e.source.getActiveSheet();
var range = e.range;
var row = range.getRow();
var emailAddress = sheet.getRange(row, 2).getValue();
var ordername =sheet.getRange(row, 3).getValue();
var ordernum = sheet.getRange(row,5).getValue();
var ordergetdate = sheet.getRange(row,6).getValue();
var mobileNumber = sheet.getRange(row, 4).getValue();
var subject = '【豐原團購】甲竹園玫瑰檸檬塔訂購成功';
var message = ordername+'您好:提醒您玫瑰檸檬塔訂購成功. 訂購數量為'+ordernum+'盒,預計取貨日為:'+ordergetdate;
if (emailAddress) {
MailApp.sendEmail(emailAddress, subject, message);
}
// 發送簡訊
if (mobileNumber) {
var smsMessage = ordername+'您好,玫瑰檸檬塔訂購成功。數量為' + ordernum + '盒,取貨日為:' + ordergetdate;
sendSMS(mobileNumber, smsMessage);
}
var lineMessage= ordername+'您好,玫瑰檸檬塔訂購成功。數量為' + ordernum + '盒,取貨日為:' + ordergetdate;
sendLineNotify(lineMessage);
}
function sendLineNotify(message) {
var lineNotifyToken = 'xxxxxxxxxxxx';
var url = 'https://notify-api.line.me/api/notify';
var options = {
'method': 'post',
'payload': 'message=' + message,
'headers': {
'Authorization': 'Bearer ' + lineNotifyToken
}
};
UrlFetchApp.fetch(url, options);
}
function sendSMS(mobile, message) {
var url = 'http://api.twsms.com/json/sms_send.php';
var username = 'xxxxxxxx'; // 替換為你的用戶名
var password = 'xxxxxxxxxx'; // 替換為你的密碼
var payload = {
username: username,
password: password,
mobile: mobile,
message: encodeURIComponent(message)
};
var options = {
method: 'post',
payload: payload
};
UrlFetchApp.fetch(url, options);
}