Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

221
Visualizações
Insert text into HTML/CSS e-mail with function from a different file

I have a html/css e-mail template that I want to use to send users e-mails for things like welcoming after signing up, send secret codes, and general purpose e-mails.

I need to "inject" this html template it with custom text instead of the lorem ipsum it currently contains.

I want to make a javascript function that inserts given text into my html template, this way my e-mail service can send custom e-mail to users based on their e-mail and custom messages throughout my node app as certain events are triggered.

I have a html/css e-mail in the file generalContact.html

I am unsure of 1 how "export" it so that makeEmail.js has access to the template and 2 how to format the html email so it can accept custom input text.

Do I have to assign the template to a variable first somehow?

Any help/guidance would be appreciated, thank you.

makeEmail.js

const htmlTemplate = require("generalContact.html")

const makeEmail = (bodyText) => {
      // How can I access the HTML file and insert the above input into it?
      return emailWithTextInserted 
}

module.exports = makeEmail

generalContact.html

<!DOCTYPE html PUBLIC "-//W3C/...." "http://www.w3.org/.....">
<html xmlns="http://www.w3.org......">
  <head>
    <title></title>
  </head>
  <body>
    <center>
      <tr>
        <td>
          This is Photoshop's version of Lorem Ipsum. Proin gravida nibh vel
          velit auctor aliquet. Aenean sollicitudin, lorem quis bibendum auctor,
          nisi elit consequat ipsum, nec sagittis sem nibh id elit. Duis
          <a>
          sit amet nibh vulputate cursus a sit amet mauris.<br /><br />

          Mauris in erat justo. Nullam ac urna eu felis dapibus condimentum sit
          amet a augue. Sed non neque elit. Sed ut imperdiet nisi. Proin
          condimentum fermentum nunc. Etiam
          <a>
          erat sed fermentum feugiat, velit mauris egestas quam, ut aliquam
          massa nisl quis neque. Suspendisse in orci enim.
        </td>
      </tr>
    </center>
  </body>
</html>
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda