I know this issue is out there and I went through most of the "image not being displayed in email" questions, but nothing is helping me so far.

I am sending some images in my email.

In my controller I am generating the image url like this:


These images are associated to the object record using Attachments.

The URL comes in properly in the email but the image is not shown. When I copied the url from the email and put it into another tab, it went to Salesforce login screen instead of showing the image.

I even tried to change the url to this:


But it still does not show my image. When I copy that url in a new tab and hit enter it gives me following error:

Unable to Access Page The value of the "id" parameter contains a character that is not allowed or the value exceeds the maximum allowed length. Remove the character from the parameter value or reduce the value length and resubmit.

So I removed the last 3 characters of both ids to make them of length 15 but it still did not worked.

Am I doing something wrong. Any help and suggestions would be appreciated.

  • 1
    When using servlet.FileDownload to retrieve files that are added to a record as Notes & Attachments, you have to make sure that the user making the request has at least read permissions on the record that the file is attached to. This is why you got the Salesforce login screen using this method. Question: What are your requirements around relating the image files to various records? Are other options available to you, eg. Static Resources, or even externally hosted images, then adding URL links as a related list? Commented Dec 4, 2013 at 15:14
  • Well no, I only have the option to access the images from Notes and Attachments. Is there no way to make these images public in an email? Commented Dec 4, 2013 at 16:40
  • The email is also sent to a non salesforce user so I dont know how the read permission takes into effect in this case. Commented Dec 4, 2013 at 16:45
  • 1
    That's the main problem: Because the email is sent to non-salesforce users, they will not have read permissions, and so they will not be able to download the images from Notes & Attachments. I don't see any way around that, unfortunately. Commented Dec 4, 2013 at 20:06
  • Ok, so we need to 'paste' image in the email so that it becomes part of the email body & not just a link. Commented Dec 5, 2013 at 5:01

3 Answers 3


Attachments are not public hence anybody receiving the email would need a login for your org to be able to see the images you're trying to send. One alternative would be to host the images elsewhere which will likely be faster, or you could upload the images as public documents in Salesforce as you can generate a public URL for documents so that they can be viewed externally.

  1. Upload and store the image file in salesforce Documents
  2. Be sure to mark the document/image as "Externally Available Image"
  3. Once the image file has been stored, follow the syntax below to reference the image in your HTML:


{SALESFORCE-INSTANCE} = Salesforce.com instance (ex. NA1, NA2, NA3, etc.). This can be found by looking at the address field in your browser window. {ORG-ID} = Organization ID. Can be copied from Setup | Administration Setup | Company Profile | Company Information {DOC-ID} = Document ID. This is the 15-digit character string at the end of the URL when viewing the document detail in salesforce.

  • 1
    I did explored the documents solution but the client is insisting on using notes and attachment for images. I read the body from attachment and convert it to base64 and attach it in the img source. it works in this js fiddle: jsfiddle.net/HnYvG but it does not work when the actual email is sent. Upon researching I found out that gmail does not support the base64 format for images: stackoverflow.com/questions/16242489/… Commented Dec 13, 2013 at 17:57
  • I tried with the File object. I inserted the public link in the img tag. It was still not working. Commented Dec 30, 2019 at 12:10

Image should be added in Sales-force Documents that URL should be added in your Email Template. Steps:- Go to Documents tab click on New Button Enter Document Name Check check box Externally Available Image Choose file Click on save Copy the image URL .

Image should be visible on your Mobile


This seems to continue working, even in 2022. The key is to use Documents in this way, not Files, which behave quite differently.

Note that you cannot access Documents from Lightning - switch to Classic first.

You must log in to answer this question.

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