Hello there,
I have a button on a ribbon which generates an eml file and downloads it. The goal is to generate an e-mail template based on field values, entity status, etc.
The e-mail templates I have to use are long formatted text, with different fonts, colors, etc., so I put them in different html webresources.
In my JavaScript function "generateEml", I compose the eml file, and I have to get the content of an html webresource, but I'm unable to do it.
Here's the function:
const emailTo = ""
let emlCont = 'To: ' + emailTo + '\n'
emlCont += 'Subject: ' + object + '\n'
emlCont += 'X-Unsent: 1' + '\n'
emlCont += 'Content-Type: text/html' + '\n'
emlCont += '\n'
emlCont += "<!DOCTYPE html>" + emailBody
console.log(emailBody)
let textFile = null
const data = new Blob([emlCont], { type: 'text/plain' })
if (textFile !== null) window.URL.revokeObjectURL(textFile)
textFile = window.URL.createObjectURL(data)
const a = document.createElement('a')
const linkText = document.createTextNode(id)
a.appendChild(linkText)
a.href = textFile
a.id = id
a.download = object + ".eml"
a.style.visibility = "hidden"
document.body.appendChild(a)
document.getElementById(id).click()
}