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

How to render a transparent gif directly from APEX code

Hi folks,


We're trying to create a way that would allow a person reading an HTML email to view an image with a path like this:


<img src="" />


When that link is accessed, we immediately want the associated APEX code to update the related record, but also immediately display a gif image to the reader.  So far, we've done lots of research but nothing seems to work.


We have the base64 code for the image we'd like to display as well, and have tried making a VF page with contenttype="image/gif"




Any ideas or suggestions would be greatly appreciated.



Pat PattersonPat Patterson

Hi Cozimek,


You can include data inline like this in a VF page:






Hi Pat,


Thanks for the fast response.  I just tried putting in the following code into my VF page...


<apex:page contentType="image/gif" standardStylesheets="false" showHeader="false" sidebar="false">


...and I keep getting this error message in Firefox: "The image "" cannot be displayed because it contains errors."  Any ideas why we'd keep getting this?  No matter what we try, we always get this response.



Pat PattersonPat Patterson

You need to take the contentType="image/gif" out of the page header - then you'll get a VF page with just your GIF on it.


Backing up a little - what is it you're trying to achieve - something like a web bug? I'm not sure that's going to work - I don't think there's a way to render binary content as a VF page.


I haven't worked with email tracking, but it looks like this is built in for email sent from Salesforce - see


Yeah, that's what we're trying to achieve, but we've built our own app, and would like to render a web bug ourselves for our own app.




Thanks for your quick thoughts though!