I am making Visualforce email templates for a client. Some of the emails contain a section with recommended products at the bottom, which is just an image and item name displayed in a table in a row. Both of these things are links to the item on the client’s webstore. I am trying to make a solution in which the client only has to update one place to update recommended products, rather than having to update each email template individually with new recommended products.
Currently, images for the recommended products are stored as static resources. Recommended products are stored as records in a custom setting list. Each record has a field for product name (text area), static resource name (text), and product page URL (URL). A controller creates a list of the values of the recommended product records from the list. A component loops through and displays a table of recommended products. The component is then included in the email template.
In the component, this is the code line that displays the images:
With this code, the images for the products display only in the HTML preview window and not in the actual email that gets sent.
If I hard code an external image, the images display properly. I think it’s an access issue, but I’m not sure what the solution is.
In a previous version of the code, recommended product images were stored as files/documents with a public link generated for them. There was a URL-type field on the custom setting list, “ProductImage”, which contained these public links. The images were then displayed in the component with this code line:
In this code version, the images did not display in the HTML preview window OR the email that got sent.
I am not sure what a solution would be. The code works fine apart from the image; the component with a hardcoded image displays and functions how I want. Am I missing something? Is there another solution I should look at?