1

I am trying to send an email using a Visualforce template and I want that template to include an icon. Is this possible?

6

Sure, <apex:image> tag or plain old <img>.

  1. It cannot be an image from static resources though.
  2. If you want to use image hosted in your salesforce, best would be to upload it to Documents and tick the "externally available image". And then remember to use full path: https://{instance id}.salesforce.com/servlet/servlet.ImageServer?id={document id}&oid={your org ig}
  • Sorry I am a newbie. How do I upload the icon as a Document? What is the advantage of using <apex:image> over <img> – dublintech Nov 21 '12 at 12:16
  • 1
    @dublintech Go to Documents tab (https://eu1.salesforce.com/015 for me because I'm on "eu1"), pick a folder or create new one and upload it there, write down the generated document's Id :) as for the other q. - not much in this case if you don't use static resources. <img> will give you full control over HTML wheras other one will generate some markup you might don't want. But if you want to render the image conditionally (for example select "Green/Amber/Red" then the <apex:image rendered="{!conditionHere}" is best cut for it. – eyescream Nov 21 '12 at 12:25
  • hey @eyescream what about displaying a dynamic QR code image (using dynamic unique SFDC ID) on email template (html or visualforce)? link to my question -> salesforce.stackexchange.com/q/196397/38191 – compski Oct 22 '17 at 8:47
1
<apex:repeat value="{!relatedTo.NotesAndAttachments}" var="c" rows="1"> 
    <h3>Signature</h3>
    <div align="left"><apex:image url="/servlet/servlet.FileDownload?file={!c.Id}" height="100px"
        width="200px" /></div>
</apex:repeat>

If its in Notes and attachment the above code is handy and i have used and its working.

If stored in documents

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

You can pull from documents.Dont pull from static Resource .It never works .

http://boards.developerforce.com/t5/Visualforce-Development/Image-broken-in-Visualforce-email-when-delivered/td-p/160751

  • I am sending the same icon to a bunch of people in an email. How I can add the note / attachment to my custom object so that I can retrieve as you have shown? – dublintech Nov 21 '12 at 12:14
  • Ok for your requirement i would suggest you to go to the documents tab and upload the image – Mohith Shrivastava Nov 21 '12 at 12:46
  • hey @MohithShrivastava what about displaying a dynamic QR code image (using dynamic unique SFDC ID) on email template (html or visualforce)? link to my question -> salesforce.stackexchange.com/q/196397/38191 – compski Oct 22 '17 at 8:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.