Skip to main content
Created a custom vf page for the end user to update the email template and send an email but the htmlvalue of the html email template is causing an issue with the save.

Page 

Unable to save htmlValue of html email template via apex vf controller

Error after I click Save

User-added image

Code:

VF:

<apex:pageBlock title="Email Body" >

            <apex:inputTextarea value="{!emailBody}" richText="true" style="min-width:100%;height:350px;width:120px" > 

            </apex:inputTextarea>

        </apex:pageBlock>

Apex:

EmailTemplate emailTemp = [Select id,subject,body,HtmlValue from EmailTemplate where name = :templateName limit 1]; 

            emailTemp.Subject = subject;

            emailTemp.HtmlValue = String.ValueOf(body);

            system.debug('body:'+body);

            update emailTemp;
1 respuesta
  1. 4 nov 2019, 10:48
    Error:

    Update failed. First exception on row 0 with id 00X1U000000RbpLUAS; first error: 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]

    Error is in expression '{!saveTemplate}' in component <apex:commandButton> 
0/9000