You need to sign in to do that
Don't have an account?
Aaron Hill
Fields that are populated with html text, as merge fields in visualforce emails
I have a large text field on Opportunities that is populated with text formatted by html when the Opportunity is created. I use an apex trigger to do this. The field is a simple questionnare asking details about the opportunity the. The trigger only inserted html code into the field, nothing too fancy.
I created a visualforce email template with the field inside of it hoping I could send a copy of the questionnare to my team. I put the merge field inside of html tags. But when I tested the template my merge field rendered as plain text, with no line breaks, and all of the html tags.
Here is the visualforce template:
And the resulting text looked like this:
Normally I would use jQuery to re-encode the html. I saw something about using this command:
!HTMLENCODE(myobjdata).
But I've heard I can't use or shouldn't use jQuery in a visualforce email template.
I need that code to render! Can anyone help? Thanks!
I created a visualforce email template with the field inside of it hoping I could send a copy of the questionnare to my team. I put the merge field inside of html tags. But when I tested the template my merge field rendered as plain text, with no line breaks, and all of the html tags.
Here is the visualforce template:
<messaging:emailTemplate subject="RTF Email template" recipientType="User" relatedToType="Opportunity" > <messaging:htmlEmailBody > <html> <h2><em>Hello! I'm a rich text email! And the general project details for this oppy are:</em></h2><br></br><br></br> {!relatedTo.General_Project_Details__c} c <br></br><br></br> <p style="{font-size: 32px; color:purple}">Look how rich I am!!!</p> <div style="border:1px solid green"><p style="font-size: 46px; color: red">I'm the richest text ever!</p></div> </html> </messaging:htmlEmailBody> </messaging:emailTemplate>
And the resulting text looked like this:
Normally I would use jQuery to re-encode the html. I saw something about using this command:
!HTMLENCODE(myobjdata).
But I've heard I can't use or shouldn't use jQuery in a visualforce email template.
I need that code to render! Can anyone help? Thanks!
All Answers