I am using a vf email template. I understand to use logo in a vf template i cannot leverage static resources, rather have to keep the logo in documents folder. But how can i dynamically access the url of the image from the document folder in the template so that the template can be deployed to higher orgs

2 Answers 2


Refer to: https://help.salesforce.com/apex/HTViewSolution?urlname=Why-images-stored-as-static-resources-cannot-be-seen-in-emails-sent-using-VF-email-templates-1327108316482&language=en_US

It states:

To solve this problem, images should be stored in documents and with "Externally Available Image" checked. The image will be available by using the following markup:

<apex:image id="theImage" 
width="200" height="200"/>

Save the instance value in a custom setting and refer the value dynamically inside url..

  • 1
    But how does that help in migration. When the org changes the document id and ordId will also change. Could there be a way where the document id and oid be dynamically accessed so that one does not need to manually keep changing the id values as the template moves up.
    – starhunter
    Commented Apr 26, 2016 at 13:44
  • @starhunter - I guess you can use a custom component with controller and query the orgId and documentId dynamically based on certain conditions and use that component in your template.
    – Samir
    Commented Apr 28, 2017 at 11:18

You can create force.com site and use the force.com site url+document Id in email template.


  • I believe in that scenario too, I would be hard coding the document id. I was looking for a way by which the document id be dynamically accessed as the template moves from lower environment to higher environments.
    – starhunter
    Commented Apr 26, 2016 at 13:46

You must log in to answer this question.

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