I need to send an email with an HTML body using only ajax since I don't have access to the server code. Fortunately, the server has an API for sending emails.
Currently, I have a dynamically rendered component called invoiceEmail
.
sendEmail () {
const mailConfig = {
to : '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7b111413151f141e3b1e031a160b171e55181416">[email protected]</a>',
subject : 'Your Invoice',
// body : this.$refs.invoiceEmail.$el, // this doesn't work
// I'm getting error "converting circular structure to json"
body : '<strong style="color:red;">red bold</strong>', // this works
}
this.$api.POST('send-email', mailConfig)
.then(response => {})
.catch(error => {})
.finally(() => {})
},
}
If I use HTML as a string in the body
like:
'<strong>this should be bold</strong>'
, it works properly. Therefore, I believe if I can extract the HTML content, the code will function correctly.
This is
console.log(this.$refs.invoiceEmail.$el)
https://i.sstatic.net/TyyEi.png
How can I retrieve plain HTML instead of using this.$refs.invoiceEmail.$el
?