8

Referring to note section for Pt #5 at this link : http://login.salesforce.com/help/doc/en/code_email_services_editing.htm , it seems the platform doesnt support inline attachments in an email to be processed by the email handler. Is there any work around to do this ? For eg : If you have an email in HTML format, we could parse the HTML, get this image body, store it internally as an attachment and replace that with link in HTML body and store in a RIch Text area field in Salesforce.

Looking for inputs

Thanks

3
  • Are the "inline images" truly inlined, or are they HTML img tags with external URL's? Truly inlined images are getting less and less common these days.
    – jkraybill
    Commented Mar 26, 2013 at 0:53
  • Yes, they are truely inline images.. i agree with you that these are getting less common these days but customer is pretty keen to have that supported..Developer's life is not good all the times.. lol :)
    – Jatin Jain
    Commented Mar 26, 2013 at 3:24
  • @JatinJain - were you able to find a viable workaround for this problem?
    – iDog
    Commented May 20, 2017 at 18:04

2 Answers 2

1

Based on your comment that these are truly inline images, therefore using the Data URI scheme, e.g.

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA
AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot" />

I believe that you could indeed manually parse, decode, and save these images using Apex (but I have not done this myself). The steps would be:

  • Getting a hold of each image tag, then stripping out just the Base64-encoded image data.
  • Using Apex's EncodingUtil to Base64-decode each image into a Blob.
  • Save each image Blob to a place of choice within Salesforce, maybe as Attachment objects (potentially also Content or Documents).
  • Replace the source tag with a link to this new Attachment.

Of course, if Salesforce is stripping out inline image content before hitting your email handler, you're going to be totally out of luck and won't be able to use email handlers, but I doubt that is happening.

2
  • Interestingly, inline images are not ignored in Salesforce inbound email handlers and are treated as binary attachments. Hence, we might skip this step of decoding the image and insert as a blob. We just get it and store it into say Documents folder and later replace the img tag with actual url. This works!!
    – Jatin Jain
    Commented Apr 8, 2013 at 22:45
  • 3
    Inline images aren't data urls (that is a HTML5 feature that few mail clients support yet), but actual links to the attachments, where the links refer to the attachments in the email by name. This is still exceptionally common, because not everyone has a hosting service where they can keep their inline images.
    – sfdcfox
    Commented Sep 22, 2013 at 17:00
0

Jatin,

I had previously came accross this situation, the inline images which you're talking about comes as BinaryAttachments, so no need of parsing..It'll be stored as attachments. But one major issue might be that, signatures will have images ( generally, email signatures will contain images ), if the email group is known then to filter that you have to use some custom logic like detecting the "content type" and also size of the body ( match it with the image size ). If its not a known group then for each mail images in the signature will be added as attachments.

You must log in to answer this question.

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