function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
rupesh ranjanrupesh ranjan 

 After sending mail Body(Ckeditor) are coming with HTML tag. How to Remove??? 

 After sending mail Body(Ckeditor) are coming with HTML tag. How to Remove??? 
Visual force page
<apex:pageBlock >

<apex:commandButton value="Send" action="{!send}" />

</apex:pageblockSection>
<apex:outputLabel value="AddRecep" for="AddRecep"/>:<br/>

<apex:inputText value="{!AddRecep}"  id="table2"/>

 <apex:commandlink onclick="openPopup();return false;" value="Add Recipients" />  
<br/><br/>
<br><apex:outputLabel value="From" for="From"/>:
           {!$User.FirstName} {!$User.LastName}
</br>
<br/><br/>
<apex:outputLabel value="Subject" for="Subject"/>:<br/>
<apex:inputText value="{!subject}" id="Subject" maxlength="80"/>
<br/><br/>
<apex:outputLabel value="Choose Video "/>
<apex:outputLink onclick="showpopup(); return false;" > <br/>

Click here to choose session </apex:outputLink>
<br/><br/>

<apex:outputLabel value="Body" for="Body"/>:<br/>
<!--<apex:inputtextarea value="{!body}" id="body" styleClass="ckeditor" richtext="false" />-->

<apex:inputtextarea value="{!body}" id="body" styleClass="ckeditor" richtext="false" style="width: 500px; height: 150px;">
</apex:inputtextarea>
<br/><br/><br/>   
         
<apex:includescript value="{!URLFOR($Resource.CkEditor,'ckeditor/ckeditor.js')}"/>
</apex:pageblock>
 
Controller

  public pageReference send(){
   
    Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
  
    List<String> toAddress =new List<String>();
    
   
  if (AddRecep != '' && AddRecep != null) {
     toAddress = AddRecep.split(';');   
    email.setToAddresses(toAddress);
    email.setSubject(subject);
    email.setPlainTextBody(body);   
  Messaging.SendEmailResult [] res = Messaging.SendEmail(new Messaging.SingleEmailMessage[] {email});  
  for ( Messaging.sendEmailResult result : res ) {
           if ( !res[0].isSuccess () ) {
               System.debug ( result  );
           }
           else{
               ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.INFO, 'Email Sent Successfully' );
               ApexPages.addMessage(msg);
           }
       }
 }  
return null;        
}
public List<video> ConsoleWrapperList1{get;set;}
public String consolewrap{get;set;}
public void callapi2(){
     String  SessionId = '';
     for( consolewrap cwt : ConsoleWrapperList){
         if(cwt.selected){
              if(SessionId == ''){
               SessionId += cwt.sid;
              }else{
               SessionId += ','+ cwt.sid;
              }
         }
     } 
 
     List<video> ConsoleWrapperList1 = new List<video>();
    HttpRequest req = new HttpRequest(); 
    HttpResponse res = new HttpResponse();
    Http http = new Http(); 
    req.setEndpoint('http://webapi.demomail.net/test/SendVideoBody.js?id='+SessionId); 
    req.setMethod('GET');
    res = http.send(req);
    if(res.getstatusCode() == 200 && res.getbody() != null){ 
        String replaceIllegal= res.getbody().replaceAll('\n','').replaceAll('\r','').replace('','');
        ConsoleWrapperList1=(List<video>)System.JSON.deserialize(replaceIllegal,List<video>.class);   
        body = ConsoleWrapperList1.get(0).bodyT;
  
}
Mikola SenykMikola Senyk
Hi,

If I understand problem correctly you are sending plain text email. Why do you use CKEditor instead of textarea?
Anyway it is possible to get text without HTML tags.
You have to get text in JavaScript and send it to controller via action function:
<apex:commandButton value="Send" onclick="sendEmail('{!$Component.body}'); return false;" />
<apex:actionFunction name="send" action="{!send}" reRender="nothing">
            <apex:param assignTo="{!plainTest}" name="text" value=""/>
</apex:actionFunction>

...

<script>
        function sendEmail(editor) {
            send(CKEDITOR.instances[editor].document.getBody().getText());
        }
</script>

 
Mikola SenykMikola Senyk
But better approach is to change line:
email.setPlainTextBody(body);
to:
email.setHtmlBody(body);
It helps to keep text formatting.