I have written a script to send an email alert if products of a certain type are missing from a quote.
Very straightforward, very simple.
All I want to do now is include in the email some basic info like sales rep and division.
I know I can do the +repName etc like below.
However when I do this there are no spaces and everything is on one line.
So I want to do some basic formatting, a couple of line breaks, a field label.
But if I put repName or itemDivision in between the quotes then they appear as just the text, not the variable values.
How do I insert the variables into the body of an email so I can format them? I assume I have to enclose them in tags of some kind?
Cannot find the information anywhere.
Not interested in any fancy complex rendering techniques or writing a million lines of code. The information is already there, I just want to include in a slightly more visually friendly way.
Thank you
log.debug({
title: 'Line Item Division',
details: itemDivision
});
if (itemDivision !== 'Media') {
email.send({
author: ** ** ,
recipients: 'an email address',
subject: 'Quote Without Media',
body: "A Test" + itemDivision + repName
});
}
}
2
Answers
Many thanks to Sean in the comments.
After the initial section in quotes " " if you want to add more HTML tags then you need to use a + before the new section So "Some text" +variable +"Some more HTML" +variable etc.
Avoid the pitfalls of concatenating a bunch of strings by using a template literal. Note the use of backticks instead of quotes to indicate it’s a template literal.