I've tried to set default value to emailBody attribute of the apex:emailpublisher component with an HTML value along with setting emailbodyformat to "HTML", but when I opened the console it renders the default value without the <br /> elements.

The visualforce page code:

<apex:page standardcontroller="Case" extensions="CTRL_Case_EmailReplyAll">
<apex:emailpublisher id="myEmailPublisher"
                     title="Reply All"
                     emailbody="<html><body>Hi,<br /><br />Your ticket has been marked as solved. You can re-open it by replying to this email.<br />Below is the full thread, for your record,<br /><br />Regards,/<br /><br /></body></html>"
                     onsubmitfailure="alert('failed');" /></apex:page>

The result on the service console: enter image description here

Do you have any clue how to set it right, so it won't ignore the newline elements?


The Service Console is using a Rich Text editor, not an html editor. That means you'll need to use a text string that includes newline character codes where you want them. A \n is a newline character and a \r is a carriage return. I'd expect either one of those to do the job for you.

You may need to use escapeUnicode() on the text string to convert those to unicode characters for the editor.

  • This works only when I set the "emailbodyformat" property to "text" and that's a problem because the content contains images too. Have you managed to solve it in such a case too?
    – Elad Khalo
    Jul 24 '16 at 14:57
  • Didn't realize you were sending it with images. You could try using escapeHTML4() with your original syntax. StripHTMLTags() would remove all of the html tags without touching the newline characters. You may need to use some combination of these to achieve what you desire. See string methods for more.
    – crmprogdev
    Jul 24 '16 at 16:58
  • Unfortunately, none of these works. It looks like the control itself removes the new line characters or ignore it when I try to set default value, regardless any manipulation I do before setting it. I wonder if there any workaround or other way to get the same result.
    – Elad Khalo
    Jul 25 '16 at 11:07
  • I would suggest trying several different things. One is to try including the text as PlainTextBody with the unicode characters for the newlines or carriage returns. Try doing the same for the HTMLbody to see if either one works for you; especially since neither one is being set. I'd also try using setTreatBodiesAsTemplate(treatAsTemplate). Finally, use setCharset(characterSet) and select a unicode set that includes the newlines and carriage returns you need. After that, I'm out of ideas.
    – crmprogdev
    Jul 25 '16 at 15:04

You can include the Outgoing Email text as a Custom Field and merge to the emailbody parameter. Also, use 'innerHTML' as follows:

emailBody="{!case.HTMLbody}" id="RTF"/>
      <div style="display:none">
          <div id="html">
              <apex:outputText value="{!case.HTMLbody}" escape="false"></apex:outputText>

          CKEDITOR.on( 'instanceReady', function( evt ) {

Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.