Thanks for taking a look at my problem.
I am building a VisualForce page to email all CampaignMembers associated with a Campaign record. Everything is working except for one little thing:
I have an tag that is rendered when the user clicks "Edit Template". The idea is that the user can preview the email that is going to be sent, which I do by displaying the EmailTemplate.HtmlValue with .
Here's my relevant code:
<!--VisualForce Page -->
<apex:pageBlockSectionItem rendered="{!editMode}">
<apex:outputLabel value="Edit Template" />
<apex:inputTextarea id="editTemplate" value="{!strMessage}" richText="true" cols="100" rows="15"/>
</apex:pageBlockSectionItem>
/* Controller */
editedTemplate.HtmlValue = strMessage;
update editedTemplate;
So the problem I am getting, when using the rich-text editor, is the following exception:
FIELD_INTEGRITY_EXCEPTION, The HTML Email Content contains improperly formatted merge fields. Please check the format of all the merge fields to ensure they start with {! and end with }.: [HtmlValue]
Although I can get it to work with the plain-text editor. However, it is displayed like this:
<table height="400" width="550" cellpadding="5" border="0" cellspacing="5" >
<tr height="400" valign="top" >
<td style=" color:#000000; font-size:12pt; background-color:#FFFFFF; font-family:arial; bLabel:main; bEditID:r3st1;" tEditID="c1r1" locked="0" aEditID="c1r1" >
<![CDATA[<font face="arial"><font size="3">Dear </font>{!Contact.Salutation} {!Contact.LastName},</font><div style="color: rgb(0, 0, 0); font-family: arial; font-size: 12pt;"><br></div><div style="color: rgb(0, 0, 0); font-family: arial; font-size: 12pt;">How are you today? I enjoyed our meeting, let's meet again soon!</div><div style="color: rgb(0, 0, 0); font-family: arial; font-size: 12pt;"><br></div><div style="color: rgb(0, 0, 0); font-family: arial; font-size: 12pt;">Sincerely,</div><div style="color: rgb(0, 0, 0); font-family: arial; font-size: 12pt;"><br></div><div style="color: rgb(0, 0, 0); font-family: arial; font-size: 12pt;"><font face="arial"><b>{!User.Name}</b></font></div><div style="color: rgb(0, 0, 0); font-family: arial; font-size: 12pt;"><font face="arial">{!User.CompanyName}</font></div><div style="color: rgb(0, 0, 0); font-family: arial; font-size: 12pt;"><font face="arial">{!User.Phone}</font></div><div><font face="arial">{!User.Email}</font></div><div style="color: rgb(0, 0, 0); font-family: arial; font-size: 12pt;"><font face="arial"><br></font></div>]]></td>
</tr>
</table>
Unformatted HTML is not appropriate for displaying to the end-user.
Any ideas why the rich-text editor would cause the exception above? What can I do to fix it?