【发布时间】:2021-12-30 14:54:08
【问题描述】:
我正在尝试根据某些条件从 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: "test@test.com"
});
电子邮件看起来像这样:
“您好,XYZ,感谢您的预订。 您已预订:一些 - 旅游 旅游详情: 旅行日期:2021 年 12 月 24 日星期五"
它在第一个 if 语句处停止。在这个特定的例子中,if 语句 == true,所以它应该添加它的内容以便继续脚本。
【问题讨论】:
标签: google-apps-script google-sheets gmail-api