+ Start a Discussion
RupaliJRupaliJ 

RichText Area not removing HTML Tags

Hi,

 

I am developing a Send Email Module to add some more functionality. I have a Rich text area to show selected template body.

 

<apex:inputtextarea richtext="true" value="{!body}" id="body"/>  

{!body} is string property.  Suppose Template is as below :

 

Dear {!Contact.FirstName}, I really enjoyed speaking with you today. I think that {!Organization.Name} has a lot to offer {!Account.Name} and I look forward to our next meeting.Regards, {!User.FirstName}

 When I edit template body to :

Dear {!Contact.FirstName}, I really enjoyed speaking with you today. I think that {!Organization.Name} has a lot to offer {!Account.Name} and I look forward to our next meeting.

Waiting for you reply.

Regards, {!User.FirstName}

 

 then in controller I get template with HTML tags

Dear {!Contact.FirstName}, I really enjoyed speaking with you today. I think that {!Organization.Name} has a lot to offer {!Account.Name} and I look forward to our next meeting. 
<br/>
Waiting for you reply.
<br/>
Regards, {!User.FirstName}

 Can anyone help me to resolve this? Trying hard to avoid html tags but no success :(

 

 



 

 

Best Answer chosen by Admin (Salesforce Developers) 
Harshala Shewale (Salesforce)Harshala Shewale (Salesforce)

Use regex

 

body = body.replaceAll('<[^>]+>',' ');

 

It will solve the problem.

 

 

All Answers

Harshala Shewale (Salesforce)Harshala Shewale (Salesforce)

Use regex

 

body = body.replaceAll('<[^>]+>',' ');

 

It will solve the problem.

 

 

This was selected as the best answer
Charni WigginsCharni Wiggins
Hi, how exactly do you incorporate the regex into the email template? I am doing the same, but using a workflow to populate the email template with a rich text field, but can't seem to remove the html markup. Thank you