4

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"
                     entityid="{!case.id}"
                     width="100%"
                     title="Reply All"
                     expandableheader="false"
                     autocollapsebody="false"
                     showadditionalfields="false"
                     fromvisibility="selectable"
                     tovisibility="editable"
                     bccvisibility="hidden"
                     ccvisibility="hidden"
                     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>"
                     emailbodyformat="HTML"
                     subject=""
                     showtemplates="false"
                     toaddresses="{!toAddresses}"
                     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?

2

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.

| improve this answer | |
  • 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
0

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>
          </div>
      </div>


       <script>
          CKEDITOR.on( 'instanceReady', function( evt ) {
              evt.editor.setData(document.getElementById('html').innerHTML);
          })
      </script>

Hope this helps.

| improve this answer | |

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.