Convert email html body from multipart/alternative to UTF-8
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2023 09:19 AM
Hello experts,
I'm looking for a way to convert email html body to utf-8. (as sender cannot parse it before sending to SN side).
I tried to adjust this piece html code which do working on the web:
function strip(html)
{
var tmp = document.createElement("DIV");
tmp.innerHTML = html;
return tmp.textContent||tmp.innerText;
}
alert(strip(document.body.innerHTML));
Inbound action code:
var finalb = strip(email.body_text);
current.description = finalb;
function strip(html) {
gs.log("Tomer - html is " +html,"Tomer");
var tmp;
tmp.innerHTML = html;
gs.log("Tomer - inner text is " + tmp.innerText,"Tomer");
return tmp.textContent || tmp.innerText;
}
current.insert();
html is returning full html body but innerText is undefined.
any suggestion?
Thanks,
Tomer
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2023 11:32 PM
@Anand Kumar P thanks for your quick response, but still no luck 😞
var htmlBody = email.body_text.toString();
var plainText = htmlBody.replace(/<[^>]+>/g, '');
var finalb = strip(plainText);
current.description = finalb;
function strip(html) {
gs.log("Tomer - html before tmp " + html,"Tomer");
var tmp = document.createElement("DIV");
gs.log("Tomer - html after tmp " + html,"Tomer");
tmp.innerHTML = html;
return tmp.textContent || tmp.innerText;
}
html looks cleaner but not printing log after var tmp = document.createElement("DIV"); line...
