10

I have a requirement to send inline images in HTML email using SingleEmailMessage.

I seem to be stopped by an unresolvable problem caused by a gap in the Salesforce API.

Inline images require me to use a Content Id of the embedded image as the src of the image:

<img src="cid:[somerandomstring]">

And to attach the image to the email as a file attachment with the mime content id the same as I used in the img src attribute.

Unfortunately Salesforce does not seem to provide me with a property by which I can set the content ID of an attached file (it lets me pick the filename and interesting a boolean flag indicating if the image is 'inline').

Has anyone solved this problem before without resorting to a Amazon SES or Sendgrid callout?

2 Answers 2

1

A workarround could be to send real inline images: <img src="data:image/png;base64,DATA">. This would work for small images, otherwise the heap size might be a problem. A plus: the e-mail is shown without attachments in most of the e-mail-clients.

1
  • has this solution been tried? Is there a recommended best practice?
    – akaphenom
    Commented Dec 10, 2014 at 20:09
0

I tried using the approach. These images did not display in Gmail or Outlook however if you saved the email as a html file the images displayed.

The only option that doesn't use Amazon SES or Sendgrid is to have Salesforce expose a Content-Id property that we can set.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .