0

I have process that update checkbox field in object. When this happen it invoke workflow that send email with attachment, and inside the attachment images from static resources.

The process which update the checkbox run asynchrony.

It all worked ok until yesterday, when users reporting that the images are not being displayed in the attachment.

I was able to reproduce it in sandbox and it's wierd. When I updating the checkbox manually I do receive correct email with images, but when using future method to update the flag, I receive the email + attachment, but no images inside.

We didn't made any changes in the process, I wondering is there any update from SF side? Any idea what else can cause the issue?

this is how we display the logo ('imageLog' is generated in controller, and displayed inside visual component, which is inside email template)

<div class="header">
<apex:image url="{!imageLogo}" />
</div>

UPDATE

I found until now, that it doesn't related to my existing process. Created new email template:

<messaging:emailTemplate subject="Test" recipientType="User" relatedToType="Distribution_List__c">
<messaging:htmlEmailBody >
</messaging:htmlEmailBody>

<messaging:attachment renderAs="PDF" filename="testFile.pdf">
    <apex:image url="{!URLFOR($Resource.mylogo)}" width="760" height="130" />
</messaging:attachment>

</messaging:emailTemplate>

and 2 method that send email with this emplate, 1 in future other not. When using the future method I don't see image in the email that I received. Strange...

public class sendAN{

    @future
    public static void sendEmail(){

        try{
            EmailTemplate templateId = [Select id from EmailTemplate where name = 'TempEmail'];

            List<Messaging.SingleEmailMessage> allmsg = new List<Messaging.SingleEmailMessage>();
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            mail.setTemplateID(templateId.Id); 
            mail.setTargetObjectId('0034E00000QuwDn');
            mail.setSaveAsActivity(false);
            allmsg.add(mail);
            Messaging.sendEmail(allmsg,false);
        }
        catch(Exception ex){
            system.debug('###'  +ex);
        }
    }



    public static void sendEmailNofuture(){

        try{
            EmailTemplate templateId = [Select id from EmailTemplate where name = 'TempEmail'];

            List<Messaging.SingleEmailMessage> allmsg = new List<Messaging.SingleEmailMessage>();
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            mail.setTemplateID(templateId.Id); 
            mail.setTargetObjectId('0034E00000QuwDn');
            mail.setSaveAsActivity(false);
            allmsg.add(mail);
            Messaging.sendEmail(allmsg,false);
        }
        catch(Exception ex){
            system.debug('###'  +ex);
        }
    }
}
0

Last update: Confirmed with SF support that this was a bug- when sending email with pdf attachment in asynchrony mode, images form static resources/documents are not being displayed inside the attachment.

The bug was fixed by SF team.

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.