2
votes

I'm using the below script to generate an email response when a form is submitted. I'm wondering if there is a way to further refine the HTML code for the htmlBody var. For example, I would like to define "font face = "tahoma" however the addition of quotes causes the variable to break. How can I do this?

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);
}
2

2 Answers

0
votes

Use \" when you need to use " in a string.

\ is used to escape certain characters in strings in most, if not all languages.

0
votes

You can also 'play' with single quotes and double quotes like in this example where the variable color needed to be between quotes :

  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>"