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
Inv3rnoInv3rno 

Can not display background img Email template

Hi everyone,

I have a problem to sucessfully send a visualforce email within an image as background.

Everything is ok with other image in the template, using the correct syntax:

 

<apex:image id="Logo" value="https://c.cs16.content.force.com/servlet/servlet.ImageServer?id=015f0000000ADiz&oid=00Df0000001PSvt" height="120" width="120"/>

However there is no way to use that syntax into an attribute, neither into the css part.
Here what I am trying:

 

body
{
background-image:url('<apex:image id="Logo" value="https://c.cs16.content.force.com/servlet/servlet.ImageServer?id=015f0000000ADiz&oid=00Df0000001PSvt" height="120" width="120"/>');
background-repeat:no-repeat;
background-position:right top;
}

 

I have tryed with a static img, like:

 

                background-image:url('{!URLFOR($Resource.Logo)}');

it works fine on the preview but when I send the email the image is not displayed.

 

Any suggestion ?

Thanks

 

 

sfdcfoxsfdcfox

Don't use "apex:image" for that. Just do this:

 

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

Note that some email clients may block image download automatically.

 

Inv3rnoInv3rno

Hi thanks for your reply,

however I had already tryed that solution and it was working only without oid part of the URL, that is the one that discriminate your company and is needed as well if you want email a non logged in user.

If i keep the oid part as :

 

background-image:url(https://c.cs16.content.force.com/servlet/servlet.FileDownload?file=015f0000000AGsY&oid=00Df0000001PSvt);

 

i receive this kind of error:

Error: New_customer_proposal_MFAA line 9, column 124: The reference to entity "oid" must end with the ';' delimiterErrorError: The reference to entity "oid" must end with the ';' delimiter.

 

Cheers

sfdcfoxsfdcfox

Try using &amp; instead of just &. It sounds like the XML validation is not allowing an invalid character reference.

Inv3rnoInv3rno

Hi,

nice try, with &amp; it compile without errors.

Now I can see the img into the preview (that is an achieve), but still sending the email the bg-img isn't displayed.

Note that the same img is into the body with apex img tag and is displayed in the email :(

 

Many thanks for the moment.

Cheers

 

sfdcfoxsfdcfox

Like I said, many antivirus/antispam applications and firewalls specifically strip cgi parameters so as to render "tracking" elements useless. You might instead need to write something like a sites page, encoding the binary data so it can be downloaded without a CGI parameter. It sucks that it has to be this way, but there you have it.

ATUL GUPTA 94ATUL GUPTA 94

Hi there,
please make sure in Document object record 
Externally Available Image check box  is must true .