2

以下のスクリプトを使用して、フォームが送信されたときに電子メール応答を生成しています。htmlBody 変数の HTML コードをさらに改良する方法があるかどうか疑問に思っています。たとえば、"font face = "tahoma" を定義したいのですが、引用符を追加すると変数が壊れてしまいます。どうすればよいですか?

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: "no-reply@domain.com"};
  MailApp.sendEmail(toAddress, subject, htmlBody, optAdvancedArgs);
}
4

2 に答える 2

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>"    
于 2013-01-20T11:04:33.797 に答える
0

文字列で使用\"する必要がある場合に使用"します。

\すべてではないにしても、ほとんどの言語で文字列内の特定の文字をエスケープするために使用されます。

于 2013-01-20T03:54:05.413 に答える