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

Help visualforce email template not loading image when receiving email?

Hi i have created a visualforce email template, now for the preview it renders the image but when i get an email it does not render the image. I get the red cross and i have tried clicking on display all images but no luck :(




<messaging:emailTemplate recipientType="Contact" relatedToType="Applicant__c" subject="Thank you for your Application!"> <messaging:htmlEmailBody > <html> <head> <style type="text/css"> body { font-family: Verdana; font-size:12px; } table { border-width: 1px; border-spacing: 0px; border-style: solid; border-color: #000000; font-family: Verdana; font-size:12px; } td { border-width: 1px; border-spacing: 0px; border-style: solid; border-color: #000000; } </style> </head> <body> <apex:image url="{!URLFOR($Resource.Online_Application_Resource, 'Online_Application/Images/BOC_Logo.jpg')}"/><br/><br/> <p> Dear {!relatedTo.Applicant_Title__c} {!relatedTo.Applicant_Forename_s__c} {!relatedTo.Applicant_Surname__c} </p> <p> Thank you for applying for the {!relatedTo.Online_Application__r.Term__c}. Your Application is now being processed. </p> <p> Your unique application reference is {!relatedTo.Online_Application__r.Application_Reference_Number__c}. Please always quote this reference when you contact us. </p> <!--<apex:outputPanel rendered="{!IF(relatedTo.Online_Application__r.Method_of_Payment__c = 'Cheque', 'true', 'false')}">--> <p> As you have chosen to pay by <b>Cheque</b>, you will need to send us the cheque which is dated and made payable to yourself. Please make sure that you quote your name and the above reference number on the back of your cheque. </p> <!--</apex:outputPanel>--> <!--<apex:outputPanel rendered="{!IF(relatedTo.Online_Application__r.Method_of_Payment__c = 'Electronic Transfer', 'true', 'false')}">--> <p> As you have chosen to pay by <b>Electronic Transfer</b> via your Bank's internet banking service, you <br/>will need to quote the following details<br/> Sort code: *********<br/> Account number: *********<br/> Reference: <b>{!relatedTo.Online_Application__r.Application_Reference_Number__c}</b> </p> <!--</apex:outputPanel>--> <!--<apex:outputPanel rendered="{!IF(relatedTo.Online_Application__r.Method_of_Payment__c = 'Bank of Cyprus UK Account', 'true', 'false')}">--> <p> As you have chosen to pay through your existing <b>Bank of Cyprus UK Account</b>, we will collect <br/>funds from your existing account with us. </p> <!--</apex:outputPanel>--> <!--<apex:outputPanel rendered="{!IF(relatedTo.Online_Application__r.Method_of_Payment__c = 'Direct Debit', 'true', 'false')}">--> <p> As you have chosen to pay by <b>Direct Debit</b>, we will make a one off Direct Debit claim for the <br/>Bond deposit amount from the account number you have specified in your application after five <br/>working days from the date of this confirmation.<br/> Having accepted your Direct Debit details, we would like you to confirm that they are correct.<br/> Please can you check the details below.<br/><br/> <table width="60%"> <tr> <td><b>Bond amount</b></td> <td>{!relatedTo.Online_Application__r.Amount_to_be_Deposited__c}</td> </tr> <tr> <td><b>Branch sort code</b></td> <td>{!relatedTo.Online_Application__r.Direct_Debit_Sort_Code__c}</td> </tr> <tr> <td><b>Bank/Building society <br/>account number</b></td> <td>****{!RIGHT(relatedTo.Online_Application__r.Direct_Debit_Account_Number__c,4)}</td> </tr> <tr> <td><b>Account name</b></td> <td>{!relatedTo.Online_Application__r.Direct_Debit_Account_Name__c}</td> </tr> <tr> <td><b>Reference</b></td> <td>{!relatedTo.Online_Application__r.Application_Reference_Number__c}</td> </tr> </table> </p> <p> If any of the above details are incorrect, please contact Customer Service as soon as possible <br/>on 0845 850 5555* (+44 20 8267 7343 if calling from abroad) </p> <p> If your details are correct, you need to do nothing and your Direct Debit will be processed as normal. You have the right to cancel the Direct Debit at any time before it is processed. <br/>A copy of the Direct Debit Guarantee is set out below.<br/><br/> <apex:image url="{!URLFOR($Resource.BocBranding, 'DirectDebitLogo.gif')}"/><br/><br/> The Direct Debit Guarantee<br/> <ul> <li>This Guarantee is offered by all banks and building societies that accept instructions <br/>Direct Debits</li> <li>If there are any changes to the amount, date or frequency of your Direct Debit Bank of <br/>Cyprus UK will notify you 10 working days in advance of your account being debited or <br/>as otherwise agreed.</li> <li>If you request Bank of Cyprus UK to collect a payment, confirmation of the amount and <br/>date will be given to you at the time of the request.</li> <li>If an error is made in the payment of your Direct Debit, by Bank of Cyprus UK or your bank <br/>or building society, you are entitled to a full and immediate refund of the amount paid <br/>from your bank or building society <ul> <li>If you receive a refund you are not entitled to, you must pay it back when <br/>Bank of Cyprus asks you to.</li> </ul> </li> <li> You can cancel a Direct Debit at any time by simply contacing you bank of Building Society. <br/>Written confirmation may be required.Please also notify us. </li> </ul> </p> <!--</apex:outputPanel> --> <p><b> If you are eligible to receive interest wihtout tax taken off, please return the R85/R105 <br/>forms, quoting {!relatedTo.Online_Application__r.Application_Reference_Number__c} to the address below for processing. </b></p> <p> Customer Service<br/> Bank Of Cyprus UK<br/> PO Box 17484<br/> London<br/> N14 5WH<br/> </p> <p> If you have any queries relating to your application please contact Customer Service on <br/>0845 850 555 (+44 20 8267 7343 if calling from abroad). </p> <p> Your sincerely </p> <p> Bank of Cyprus UK </p> </body> </html> </messaging:htmlEmailBody> <!-- <messaging:plainTextEmailBody > Congratulations! This is your new Visualforce Email Template. </messaging:plainTextEmailBody> --> </messaging:emailTemplate>





It sounds like the image isn't showing in the email by the msg is - is that correct?


It looks like you're using a static resource - is it publicly cached?

 it should load the image before dear applicant message, and the static resource is public :(
Rasmus MenckeRasmus Mencke

Have you made sure you have the fully qualified URL for the image? You need{$resource.} ? otherwise the email client will not know where to fetch the image.


I am not sure URLFOR will give you the domain part.


Hi i changed it to


<apex:image url="{!URLFOR($Resource.Online_Application_Resource, 'Online_Application/Images/BOC_Logo.jpg')}"/><br/><br/>


now this works if i paste it in the browser address bar


but when i get the email it still has the red cross and does not load the image when clickinh download images?

Why doesn't this work for emails? Whats the point in using static resources?


if i use the old way i.e. put the imageserver url for documents then it works but u have to pass in ur org id?

Ron WildRon Wild

As a best practice you should insert the global $Site.Domain instead of hardwiring your domain name:


<apex:image url="{!$Site.Domain}{!URLFOR($Resource .Online_Application_Resource, 'Online_Application/Images/BOC_Logo.jpg')}"/><br/> <br/>

Ron WildRon Wild

Sorry, I wasn't thinking about the login requirement for the domain ... this post should help:


Rasmus MenckeRasmus Mencke

You need to make sure they URL is fully qualified and that the image is public, if it requires you to be logged into Salesforce to see the image, it will likely not work, as your session cookie most often will not be available to the email client, unless you are using a browser to access your email.