10

I've created a Visualforce HTML Email Template with multiple language translations that is associated with a Case. When selecting the template, the customer service rep will occasionally need to tweak the text from the template. For example, if sending to multiple recipients, the text needs to be edited to the plural translation. They also tend to customize the content for the customer's specific issue. The problem is that the content from the HTML Visualforce Email Template is locked and cannot be edited before sending.

Upon initial investigation, this appears to be a limitation within the HTML Visualforce Email Templates and can be corrected by making them plain text. The problem is that we have a very specific design that is outward/customer facing that needs to stay intact. I've also heard solutions of using a custom merge field, but this only gives the ability to add extra text in a specific location. We also require Visualforce due to the Custom Label translations with Translation Workbench.

I'm specifically looking for any ideas or workarounds to be able to utilize a Visualforce HTML Email Template and provide the ability to edit the text in the preview before sending to the customer. Appreciate the assistance!

Here is an example of the Visualforce HTML Email Template:

<messaging:emailTemplate
subject="{!$Label.Email_Template_Subject}" 
recipientType="Contact" 
relatedToType="Case"
language="{!RelatedTo.Case_Language__c}">
<messaging:htmlEmailBody > 
    <!--Begin English (Default)-->
        <apex:outputPanel layout="block" rendered="{!OR(RelatedTo.Case_Language__c == 'en_US',RelatedTo.Case_Language__c == '',RelatedTo.Case_Language__c == 'UNKNOWN')}">
            Welcome back, {!Relatedto.Contact.FirstName}!<br/><br/>
            Lorem Ipsum
        </apex:outputPanel>
    <!--End English (Default)-->
    <!--Begin Dutch-->
        <apex:outputPanel layout="block" rendered="{!RelatedTo.Case_Language__c == 'nl_NL'}">
            Welkom terug, {!Relatedto.Contact.FirstName}.<br/><br/>
            Lorem Ipsum
        </apex:outputPanel>
    <!--End Dutch-->
</messaging:htmlEmailBody>

3 Answers 3

4

This attribute contentEditable="true" is only an HTML attribute, so it enables you to edit the content of what is on an HTML page, but SalesForce doesn't know about your edits or send your changes out with the email.

Editable emails would really be nice, but VF e-mail templates don't seem to have that feature.

3

You can use custom labels like {!$Label.Welcome_back} in non-Visualforce template just fine, they'll work.

Don't let the fact they're not selectable in the template wizard prevent you from trying ;) A lot of the hidden gems are missing in this dumbified (erm... "end user friendly") editor. You can use most of the functions from formulas reference:

Geachte {!BLANKVALUE(Contact.Name, 'Heer of Mevrouw')}, 

Bedankt voor uw vraag. 
{!$Label.Blah_blah}

{!$Label.Kind_regards}
{!User.Name}

...at least as long as nobody decides it's a good idea to edit it in Word and then paste back to the editor in which case there will be loads of hidden <span> etc. and the {!<span>$Label.msg</span>} won't get merged server-side (surprise, surprise).


It seems that HTML editor doesn't like Visualforce and HTML email templates. But I was able to get it to work with "HTML (using letterhead)". Go give it a go - letterheads aren't great but might be close enough to what you need. And they'll be editable by mortals = less tickets to IT support.

2
  • Thanks for taking a look! We have conditionally rendered content based on the language, so we'd have to keep it in Visualforce. Unless there is another way to achieve this? I tried using VF plaintext, but the outputPanels are essentially divs, so it threw errors. Good to know about Custom Labels in regular email templates, however I don't think the automatic language translation would work - but might be worth testing out. Jan 24, 2014 at 22:28
  • Try outputPanels with layout="none" maybe? Cust labels will be great until you realize that the answering user is Dutch but the Contact's preferred comm method is French (yes Belgium, I'm looking at you, argh). If layout=none won't work - you could experiment with IF and CASE from plain old formulas...
    – eyescream
    Jan 24, 2014 at 22:34
2

I've found a workaround! After checking out the html in firebug, I discovered that the embedded iFrame used contenteditable="false" on the body tag. This was causing the content within the Visualforce email template to be "locked". To circumvent this, I added contenteditable="true" on the outermost table within the email template.

Testing looks good so far - it's working on the regular "Send an Email" page and within the publisher "Answer Customer" tab in the Service Cloud Console. Chrome and Firefox have the same behavior. One oddity - within the publisher, the backspace key doesn't work (delete and highlighting are functional though). I'll update this answer if I learn more!

5
  • can you share a bit more about the solution ?
    – Avidev9
    May 14, 2014 at 10:10
  • Please throw some light over it.. i cant find contenteditable="false" Aug 22, 2014 at 11:08
  • Would love to see more on what you have done. Could be helpful for others
    – Prady
    Jun 20, 2016 at 13:59
  • I was able to add the contenteditable=false (I added in the body itself inside the htmlemailbody). Once done, I was able to edit the body in the Send an Email page. However, when I send the email, there is no body in the email received.
    – RajeshShah
    Jul 20, 2016 at 15:24
  • Have you ever found a way to get the backspace key to work? That would make us happy :-) Aug 30, 2017 at 9:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .