0

Background

We are using Lightning. I need to create an email template that a user can use on a custom object's Activity > Email tab.

The object records meeting minutes and includes a rich text field, plus a few junction objects to participants (contacts, staff, and discussed topic with topic comment). The template should automatically load all the information in the record, including the meeting minutes, and list of participants.

The user will send the email to Salesforce users and also may cc: some other people who are not on Salesforce.

Strategy

Since it looks like you can now select Classic Email Templates in this tab, I made a VisualForce email template. I am expecting VisualForce to be my only choice because I need to display the list of participants.

Problems

1) The VisualForce template looks good, but the custom object includes a long rich text field. My test record includes an image. I tests fine in the browser but when I email it to myself from the test page in the admin console, the email's raw source includes a bad code inserted after the img src tag, breaking it. The two letters 3D are inserted immediately after the equals sign in the img src tag, that's not HTML.

This bad code is not present when I use Chrome inspect element on the test page, the original record's field, or the image rendered in the Email tab's composition window. This looks like a Salesforce bug to me. (see below code sample)

2) I tried to actually email the record to myself using the Activity > Email tab. Recipient is therefore a user (me). The template also says recipientType is User. When I click the Send button, I get this error message: "You must send visualforce templates to either a Contact or a Lead."

If this is correct then VF templates are not the solution because the user cannot select other users or type in email addresses of nonusers either. By the way we do have a Staff object for non-users for what it's worth.

Code sample (raw email message source)

<img src=3D"https://mydomain.documentforce.com/ser=
vlet/rtaImage?eid=3Da000l00000Bazu5&amp;feoid=3D00N6F00000GOqpB&amp;refid=
=3D0EM0l00000052qI"></img>

It displays fine when testing the template in the web browser:

test image rendered in browser

Any ideas? Is there a better strategy?

This is the VF template. I added display:block span to see if that would help since someone on the tubes recommended it, but no effect.

<messaging:emailTemplate subject="Meeting Minutes" recipientType="User" relatedToType="Contact_History__c">
<messaging:htmlEmailBody >
<html>
 <body>
<B>Meeting Minutes</B><BR></BR>
Comments:<BR></BR>
<span style="display:block"><apex:outputText value="{!relatedTo.Comments__c}" escape="false"/></span>
 </body>
</html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.