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>
-1

After opening a case with Salesforce Japan they told me that emailing of images is not supported. If this is true, it means that Salesforce intentionally breaks email by inserting a unicode equals sign in the img tag in email.

I have not tested to see if it only does that when specifying recipient via BCC tag.

  • I imagine it's more to do with you're sending an email to someone that may or may not be logged in. The images in a rich text field need authentication to view them. I assume the problem you're having has nothing to do with the 3D you're seeing. – Nick Cook Aug 14 at 4:48
  • Hi Nick, my email client (Mac Mail) shows broken images even when I am logged in to SFDC because the HTML code of the email has 3D between the equals sign and the quotation mark in the IMG tag, breaking the HTML syntax. If I remove the 3D and paste the link into a browser it displays fine. – skycafe Aug 21 at 10:45
  • Is Mac Mail a separate program to your web browser? When you're logged into salesforce, you're only logged into salesforce within the browser you're using. You'd need to log into Salesforce within Mac Mail for it to work, which I assume isn't possible. e.g. This has nothing to do with the 3D thing you're seeing. – Nick Cook Aug 21 at 23:30
  • Hi Nick, yes Mail is the standard email application for Mac OS X. Salesforce told me that viewing of images in external programs is not supported, so it is intentional breaking of the hyperlink by Salesforce, that's all. – skycafe Aug 26 at 5:02

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.