Salesforce Email Templates Images

Background

Marketing team provided a banner to be used in all our Salesforce email templates across different orgs. We were faced with two challenges:

  1. Ability to change the image regularly to match the client current branding
  2. Maintain the same image link across all our orgs: Dev, Integration, QA, UAT and Production

Solution

To achieve the above specifications, we used “Documents” from Salesforce in Production. Below are the steps to follow to be able to host our email templates images in Salesforce.

  1. Click on your user profile avatar and switch to Salesforce Classic Switch to Salesforce Classic.

  2. Click on the ”+” on the navigation to expand all tabs available Expand tabs.

  3. In the list of all tabs, search for “Documents” and click on it Search for documents.

  4. Click on “New” to create a new document Create new document.

  5. Enter details for your image file and select the file to upload in section 2.
    Make sure to select the checkbox ‘Externally Available Image’ to be able to use the image in HTML templates.
    This creates a publicly available link for your image. Upload image.

  6. Once you click on “Save”, you will be redirected to the new document record page Document record page.

  7. To get the image link, right click on the image displayed and click on “Copy Image Address” Obtain image link.

  8. When you paste the link, you will get something like this:
    https://your-org.develop.file.force.com/servlet/servlet.ImageServer?id=XXXXXXXXXX&oid=YYYYYYYYYYY&lastMod=ZZZZZZZZZZZ

    For the image to change every time you update it, remove the lastMod paramater and its value from the link.
    The final link should be in the format:
    https://your-org.develop.file.force.com/servlet/servlet.ImageServer?id=XXXXXXXXXX&oid=YYYYYYYYYYY

  9. To change the image, on the document record page, just click on the “Replace Document” button (see step 6 for screenshot) and upload a new image.
    With the above link, the image will be automatically updated with the new one.

Conclusion

I prefer this technique over static resources and Salesforce Files since:

  1. Images can be uploaded to Production, only one org, and the link is used in all lower environments
  2. It provides an easy way to quickly change images to match brand identity



Photo used in social media banner by Tamanna Rumee on Unsplash