#How to send an email with HTML syntax instead of HTML text

39 messages · Page 1 of 1 (latest)

solemn sequoia
#

I want send an email with HTML syntax instead of HTML text like this

<!DOCTYPE html > <body data-id="__react-email-body"><a data-id="react-email-button" target="_blank" style="line-height:100%;text-decoration:none;display:inline-block;max-width:100%;padding:0px 0px"><span><!--[if mso]><i style="letter-spacing: 0px;mso-font-width:-100%;mso-text-raise:0" hidden>&nbsp;</i><![endif]--></span><span style="max-width:100%;display:inline-block;line-height:120%;mso-padding-alt:0px;mso-text-raise:0">Click me</span><span><!--[if mso]><i style="letter-spacing: 0px;mso-font-width:-100%" hidden>&nbsp;</i><![endif]--></span></a></body>
frigid fjord
#

What is "HTML text"? I am not aware of any formal definition of this or how "HTML text" differs from "HTML syntax". What I see here is just HTML. This only differs from how HTML normally looks in 2 ways:

  1. Line breaks and indents are absent.
  2. It contains conditional comments, which were once common during the browser wars, but now they are very rarely used in web development. They are still useful in HTML mail because mail clients do not fully implement all the features present in regular browsers.
dire cypress
#

You can save the innerHTML as a txt

solemn sequoia
# frigid fjord What is "HTML text"? I am not aware of any formal definition of this or how "HTM...

HTML text is

<!DOCTYPE html > <body data-id="__react-email-body"><a data-id="react-email-button" target="_blank" style="line-height:100%;text-decoration:none;display:inline-block;max-width:100%;padding:0px 0px"><span><!--[if mso]><i style="letter-spacing: 0px;mso-font-width:-100%;mso-text-raise:0" hidden>&nbsp;</i><![endif]--></span><span style="max-width:100%;display:inline-block;line-height:120%;mso-padding-alt:0px;mso-text-raise:0">Click me</span><span><!--[if mso]><i style="letter-spacing: 0px;mso-font-width:-100%" hidden>&nbsp;</i><![endif]--></span></a></body>
#

Example of HTML syntax

frigid fjord
solemn sequoia
#

but it still send me a text instead of HTML

frigid fjord
solemn sequoia
#

In response I got this

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><a data-id="react-email-button" target="_blank" style="line-height:100%;text-decoration:none;display:inline-block;max-width:100%;padding:0px 0px"><span><!--[if mso]><i style="letter-spacing: 0px;mso-font-width:-100%;mso-text-raise:0" hidden>&nbsp;</i><![endif]--></span><span style="max-width:100%;display:inline-block;line-height:120%;mso-padding-alt:0px;mso-text-raise:0">Click me</span><span><!--[if mso]><i style="letter-spacing: 0px;mso-font-width:-100%" hidden>&nbsp;</i><![endif]--></span></a>
frigid fjord
frigid fjord
frigid fjord
solemn sequoia
#

And got the same result

frigid fjord
solemn sequoia
frigid fjord
#

It includes this snippet:

const data = await resend.emails.send({
      from: "Acme <[email protected]>",
      to: ["[email protected]"],
      subject: "hello world",
      html: "<strong>it works!</strong>",
    });

The html key must be used.

frigid fjord
solemn sequoia
#
const resend = new Resend(process.env.VITE_RESEND_PUBLIC);

app.post('/send-email',  async (req: Request, res: Response) => {
     try {
       const { from, to, subject, react } = req.body;

     console.log('-------------------------')
     console.log('from - ',from)
     console.log('to - ',to)
     console.log('subject- ',subject)
     console.log('react - ',react)
     console.log('-------------------------')

    const data = await resend.emails.send({
      from:from,
      to:to,
      subject:subject,
      react:react,
    });
     res.sendStatus(200);

    console.log(data);
  } catch (error) {
    console.error(error);
     res.sendStatus(500);
  }
})
frigid fjord
frigid fjord
solemn sequoia
frigid fjord
#

Actually, don't use the strong tag at all.

#
html: react,
solemn sequoia
#

With this I got this

frigid fjord
solemn sequoia
#

With this

html:`${react}`,
frigid fjord
solemn sequoia
#

I got this

#

Thank you so much

#

I tried it first time - and I got another result

#

I not first time see how the same code works differently