2013-01-20 40 views
1

我使用下面的腳本在提交表單時生成電子郵件回覆。我想知道是否有一種方法可以進一步優化htmlBody var的HTML代碼。例如,我想定義「字型=‘宋體’,然而加引號的,則可變折斷。我怎樣才能做到這一點?如何在Google Spreadsheet腳本中定義HTML參數?

function onFormSubmit(e) { 
var custName = e.values[2]; 
    var toAddress = e.values[3]; 
    var subject = "Thank you for your Support Request"; 
    var htmlBody = "<h2>Hi " + custName + ",</h2><br/><Thank you for contacting our support team. Your support ticket has been created and one of our support engineers will be in touch shortly to help you resolve your issue and answer any questions you may have. Please do not reply to this message via e-mail. This address is automated, unattended, and cannot help with questions or requests.<br/><hr><i>Company Name: " + e.values[1] + "<br/>Ticket type: " + e.values[4] + "<br/> Priority: " + e.values[5] + "<br/>Ticket Subject: " + e.values[6] + "<br/>Description: " + e.values[7] + "</p1></i>"; 
    var optAdvancedArgs = {name: "Support Team", htmlBody: htmlBody, replyTo: "[email protected]"}; 
    MailApp.sendEmail(toAddress, subject, htmlBody, optAdvancedArgs); 
} 

回答

0

使用\"當你需要在字符串中使用"

\來逃避大多數字符串某些字符,如果不是所有的語言。

0

你也可以「玩」單引號和雙引號就像這個例子,其中變量color需要的是間報價:

var html = "One (or more) event removed <B>in RED</B> as shown below<BR><BR><TABLE border = 1 cellpadding = 5 bgcolor='"+color+"'><EVENTS></table>"  
相關問題