• samforce
  • 0 Points
  • Member since 2010

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 1

Images in PDF attachment of a Visualforce email Template are missing in time based workflows or when called from @future method:


I have a VF email template which references images from a static resource. This works perfectly, if I send the email from workflow rule, except for, if it is a time based workflow or if the workflow is a result of a change made in a @future apex method.


The email is still sent out, but all images are missing and are replaced by the standard VF-icon for missing images.


Easy Steps to reproduce:


1. create a simple VF email with PDF attachment



<messaging:emailTemplate subject="BugTest" recipientType="Contact">
<messaging:htmlEmailBody >

<messaging:attachment renderAs="pdf" filename="bugTest.pdf">
<img src="{!URLFOR($Resource.pdfLogo)}"/>



2. create a method which uses the template (replace the IDs with IDs from your org)




public static void sendBuggyMails() {
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { email });


3. Call the @future.method e.g. from execute anonymous


==> you receive an email with a PDF attachment but without the image


4. Remove the @future annotation and call the method again


==>  you receive an email with a PDF attachment including the image



The same issue happens, when the email is sent from a time based workflow, or from a workflow which was triggered from a @future-method.



Is this a bug or am I doing something wrong here?










  • November 03, 2009
  • Like
  • 0