我正在嘗試根據某些條件從 Google 電子表格創建旅游確認電子郵件。
如果陳述句和 id 未顯示在電子郵件中,我創建了一個變數來添加。
var mailContent =
'Hello ' customerName ', thank you for the booking.<br><br>' "You have booked: " tourName " - " tourType
"<br><br><b>Tour Details:</b> "
"<br>Travel Date: " tourDate
if (tourLang !== "--------"){
"<br>Language: " tourLang
}
"<br>Pickup adress: " tourPickup
if (tourTime !== ""){
"<br>Pickup Time: " tourTime
}
"<br>Number of Participants: " tourPax
"<br><br> <b>Contact Details: </b>"
"<br> Main customer: " customerName
"<br> Phone: " customerPhone
if (customerOtherNames !== ""){
"<br> Names of all Participants: " customerOtherNames
}
GmailApp.sendEmail(
customerEmail,
'Booking Confirmation ' voucherRealNumber,
mailContent,
{
htmlBody: mailContent,
attachments: [createPDF],
bcc: "[email protected]"
});
電子郵件如下所示:
“您好 XYZ,感謝您的預訂。您已預訂:一些 - 旅游詳情:旅行日期:2021 年 12 月 24 日星期五”
它在第一個 if 陳述句處停止。在這個特定的例子中,if 陳述句 == 真,所以它應該添加它的內容以便繼續腳本。
uj5u.com熱心網友回復:
在附加到if陳述句中時,您需要指定正在使用的變數。您尚未指定要附加字串的變數,這就是它沒有顯示預期輸出的原因。請參閱下面的示例腳本:
腳本:
customerName = 'XYZ';
tourName = 'Some';
tourType = 'Tour';
tourDate = 'Fri Dec 24 2021';
tourLang = 'lang';
tourTime = 'time';
customerOtherNames = 'other names';
tourPickup = 'pickup';
tourPax = 'pax';
customerPhone = 'phone';
var mailContent =
'Hello ' customerName ', thank you for the booking.<br><br>' "You have booked: " tourName " - " tourType
"<br><br><b>Tour Details:</b> "
"<br>Travel Date: " tourDate
if (tourLang !== "--------") {
mailContent = "<br>Language: " tourLang
}
mailContent = "<br>Pickup adress: " tourPickup
if (tourTime !== "") {
mailContent = "<br>Pickup Time: " tourTime
}
mailContent = "<br>Number of Participants: " tourPax
"<br><br> <b>Contact Details: </b>"
"<br> Main customer: " customerName
"<br> Phone: " customerPhone
if (customerOtherNames !== "") {
mailContent = "<br> Names of all Participants: " customerOtherNames
}
Logger.log(mailContent);
輸出:

轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/404529.html
標籤:
上一篇:如何將未指定數量的變數傳遞給GoogleApps腳本自定義函式
下一篇:Haskell函式回傳其輸入
