function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
gtuerkgtuerk 

Image broken in Visualforce email when delivered

I am using a static resource which is our company's logo in a visualforce email.  I get the image to show up when previewing from the app but not when the email is delivered.  I noticed another post that indicates you may need to construct the url for the image in a different way (like in a controller class).  Any ideas?

 

<apex:image value="{!URLFOR($Resource.ZayoLogo)}"/>

 

 

Best Answer chosen by Admin (Salesforce Developers) 
frasuyetfrasuyet

@TehNrd is correct.  Static image resources are not supported with Visualforce email templates. Support verified this as well.

 

http://www.salesforce.com/us/developer/docs/pages/index_Left.htm#StartTopic=Content/pages_email_templates_stylesheets.htm?SearchType=Stem
 

Instead I used the document approach using the image url below where id is the document id of the image and oid is the org id.

 

<apex:image url="https://tapp0.salesforce.com/servlet/servlet.ImageServer?id=01570000000jmOe&oid=XXXXXXXXXXXXXXX"/>

 


All Answers

TehNrdTehNrd
Try making the static resource public....but I still don't think that will work. I'm pretty sure you will need to host the image in the document object and make it externally available.
gtuerkgtuerk
Yeah, I made the resource public but no dice - didn't work.  I've also tried hosting in Box.net but having some issues with that as well.  Has anybody put an idea on idea exchange or put in a case with SF support about this?  It seems like a broken feature from what I can tell
frasuyetfrasuyet

I am experiencing the same behavior and opened a ticket with Support which quickly got escalated to Tier 3. My static resouce is public and am using <apex:image url> as well.

 

<apex:image url="https://tapp0.salesforce.com{!$Resource.Inventory_Close_Out_Email_Header}"/>

 

 

What did you end up on doing with your images? Did you defer to using Documents?

 

 

gtuerkgtuerk

I deferred the requirement until I could spend more time on it.  I was thinking about putting the resource out on Box.net and loading it from there.  Let this thread know when/if you get resolution

thanks

g

TehNrdTehNrd
Only way to get this to work right now is if you host the file as a document.
frasuyetfrasuyet

@TehNrd is correct.  Static image resources are not supported with Visualforce email templates. Support verified this as well.

 

http://www.salesforce.com/us/developer/docs/pages/index_Left.htm#StartTopic=Content/pages_email_templates_stylesheets.htm?SearchType=Stem
 

Instead I used the document approach using the image url below where id is the document id of the image and oid is the org id.

 

<apex:image url="https://tapp0.salesforce.com/servlet/servlet.ImageServer?id=01570000000jmOe&oid=XXXXXXXXXXXXXXX"/>

 


This was selected as the best answer
MLamb2005MLamb2005

I found this thread very helpful, just a quick note for anyone who stumbles on this that had me banging my head on my keyboard for a while.  You need to replace three things in the link supplied by @frasuyet to make it work:

 

https://AAA.salesforce.com/servlet/servlet. ImageServer?id=BBB&oid=CCC

 

AAA = your SFDC server, found in the URL of any SFDC link after you log in

BBB = the record ID of your publicly available document

CCC = your organization ID


I'd advise testing it in a browser until you get it right, much easier that way.

colemabcolemab

Thanks for the thread.  It was very usefull for getting my template going.  I love how we have to hard code a document ID to get this working.  I mean, isn't that against best practices?  

ChrissieChrissie

THANK YOU for pointing this out!!

Inv3rnoInv3rno

What about if you want to use an img within an html attribute like background-image:url(....);

if you do this:

 

background-image:url(<apex:image id="Logo" value="https://c.cs16.content.force.com/servlet/servlet.ImageServer?id=015f0000000ADiz&oid=00Df0000001PSvt"/>);

 

no compile errors but the image is not displayed when you send the email.

Any advise?

Gaurish Gopal GoelGaurish Gopal Goel

I have created Custom Email Template and using <img> tag to put an image.

 

I have uploaded the image in the Documents and made it externally available. But still it doesn't show the image in the HTML Preview.

 

I am working in the Sandbox environment. Does it matter ?

kevin.chileskevin.chiles

This post just saved my FACE!  Thank you Obi Wan


frasuyet wrote:

@TehNrd is correct.  Static image resources are not supported with Visualforce email templates. Support verified this as well.

 

http://www.salesforce.com/us/developer/docs/pages/index_Left.htm#StartTopic=Content/pages_email_templates_stylesheets.htm?SearchType=Stem
 

Instead I used the document approach using the image url below where id is the document id of the image and oid is the org id.

 

 

<apex:image url="https://tapp0.salesforce.com/servlet/servlet.ImageServer?id=01570000000jmOe&oid=XXXXXXXXXXXXXXX"/>