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

Visualforce Page Attachment via Invokable Method


the below class is invoked via Process builder and meant to email a dynamic visualforce attachment. 
public class EmailInvoked {

    public static void sendEmail(List<Id> lstId){
        List<String> EmailIds = ''.split(',');
        PageReference ref = Page.WorkDocket;
        Blob b ;
        b = ref.getContent();


        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();

        Messaging.EmailFileAttachment efa1 = new Messaging.EmailFileAttachment();

        String addresses;
        email.setSubject( 'Check VF From PB' +String.valueOf(;
        email.setToAddresses( EmailIds  );
        email.setPlainTextBody('Hey there, I am an email Body');
        email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa1});
        Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});

However, I would need to 
1. Not only have this email send to a static address but based on a field in the Case - Site_Email__c 
2. The Visualforce page is currently attached but only the static contect. For example apex:output fields are not rendered. How do i get the ID in the visualforce page to render correctly? 

Thank you. All help much appreciated. 
Sukanya BanekarSukanya Banekar

To set email id dynamically from case record you need to query on case record with lstId (I hope they are id's of case). You can get email field and add the same in list of email id.

I am not getting your 2nd question can you elaborate?

Sukanya Banekar