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

Pdf attachment to Visualforce Email template not displaying images.

I have a Visualforce email template that has been working fine for a while now. The template has a
text body section and a pdf generated attachment with some images in it. The images are hosted under Documents in Salesforce and are available externally.
When the template is previewed the images show up just fine in the pdf attachment.

However, when the email goes out in response to people completing a web-to-lead form the pdf attachment has no images.

Has anything changed with the pdf rendering recently? How should the images be hosted for the pdf renderer to find them and correctly insert them into the doc.

I have also tested by inserting the images into the body of the email (by creating an html section) and the images showed up. However, in the pdf section they do not.

Please provide some assistance.

Thank you.

See code below:

<messaging:emailTemplate recipientType="lead"
    subject="Thank you for your donation"
    replyTo="..." >
    <messaging:plainTextEmailBody >        

    <messaging:attachment renderas="pdf" filename="Shipping_Label.pdf">

<table border="0" cellpadding="30">
     <td align="center">
     <table border="0" cellpadding="10">
         <td colspan="3" align="left">
          Tracking ID: {!recipient.Id}
         <td colspan="2" rowspan="5" align="left" valign="top">        
            <img src="" width="121" height="216"/>                        
        <td align="left" valign="top" width="5">FROM:</td>
        <td align="left" width="250">
                 {!}<br />
                 {!recipient.Street}<br />
                 {!recipient.City}, {!recipient.State} {!recipient.postalcode}<br /><br />
            POSTAGE DUE COMPUTED BY<br />
            DELIVERY UNIT<br /><br />
        <td colspan="3">&nbsp;</td>

        <td align="right" valign="bottom" colspan="2"  width="250">
            POSTAGE_______<br /><br />
            TOTAL POSTAGE AND FEES DUE $_______<br /><br />
        <td align="left" valign="bottom" colspan="2">
            <h1>PARCEL POST</h1>

            <td align="center" colspan="3">
        <img src="" alt="Postage Due Unit" width="392" height="147" />   

Sean McMickle 11Sean McMickle 11

I know this is 10 years too late, however, I just ran into this issue myself.  Didn't change anything with the visualforce email at all, yet images vanished.  

I noticed that we had another email where the images were working, and the visualforce code looked exactly the same.  So I dug into the apex.

The only difference is that I found out that in a previous update, we had added a DML statement that fired before the email that had invisible images was sent out.   I simply the DML statements after the sending of the email, and TADA!  The images in the PDF magically reappeared. 

What a strange bug.

Sean McMickle 11Sean McMickle 11
I simply moved * the DML statements after sending the email instead of before.