42
Views
8
Comments
HTML to Plain Text
Application Type
Reactive

Hello All,
      I want to send an Email in outsystems11, where I need to get all details from the user To, CC, and Attachments, Subject, Content - Except content all is fine, I have saved the content returned by CKEditor which given in HTML and i have converted to Binary and Saved that in DB, Here i need to generate the mail once user clicks send Email, I am unable to convert that HTMl to plain text in Email widget as unable to add any client events to call JS. Also, i have tried to fix it by creating a block, but I am unable to call the block in Email.
Is there any solution for that?
Need to display the content given as input by the user and not the HTML content returned by Editor.
Thanks,
Rakesh


SampleMail.png
2025-09-01 03-21-07
Vibhor Agarwal

Hello @Rakesh K ,

To convert this into plain text for use in the OutSystems Email widget, you can use a server-side action that strips HTML tags and decodes HTML entities 

  • Use RegexReplace to remove HTML tags 
  • Use HtmlDecode to decode entities like & to &.

Warm Regards,

Vibhor Agarwal

UserImage.jpg
Rakesh K

Hello Agarwal,
  Thanks for responding!
I am using an HTML-to-text conversion to produce email content. However, the emails contain tables, and the conversion flattens them into paragraphs rather than preserving the table structure. Could you advise how to keep the table formatting in the plain-text version? 
Thanks,
Rakesh

MailText.png
editortext.png
2025-09-01 03-21-07
Vibhor Agarwal

Hello @Rakesh K ,

You can use the libraries-:


html2text: Converts HTML to Markdown

html-table-to-text: Specifically designed to convert HTML tables to readable text.


Warm Regards,

Vibhor 

2025-08-07 06-30-56
Amit J
Champion

Hi ,

See you can do one thing , you can also save Plain text in one more column for email purpose using the below method 
So when you want to plain text use it.

reference
https://www.outsystems.com/forums/discussion/62031/how-to-remove-the-html-tags-from-the-content/


UserImage.jpg
Rakesh K

Hello Amit,
   Thanks for your response,
Currently am converting that HTML to text, Am getting as plain text, Is there any way to maintain that same format which is given by User?
Thanks

2025-08-07 06-30-56
Amit J
Champion

See, you told you have binary text data , so try to use 

BinaryDataToText(TEMPLATE_CONTENT, "UTF-8")
while bind with mail without removing the html format.


2024-07-12 05-57-50
Gourav Shrivastava
Champion

Hello @Rakesh K ,

Yes, as Amit said that you need to save the plain version for better results in DB so that you can easily show it on the Email widget.

Alternatively, if you have less content so you can simply use regex for tha like i am getting nice results with less data. Like with this:- 

Regex_Replace("<p>Hello User,</p><p>Testing Email,<br>Thanks & Regards,<br>Rakesh</p> ","<[^>]*>",NewLine())


I am getting this, or you can also use "" if you don't want a new line:- 


Thanks 

Regards 

Gourav Shrivastava



Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.