skip to Main Content

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


  1. Chosen as BEST ANSWER

    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.


  2. 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.

    body: `
    <div>${repName} claims that ${itemDivision} is the best division</div>
    <div>for more info <a href='someurl?rep=${repName}&division=${itemDivision}'>click here</a></div>
    `
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search