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
NewInternNewIntern 

Simple passing of values from a LOCAL Apex variable list to FileAttachments

Usual page and custom controller stuff. 

 

There is this custom VF page that simulates the standard Send an Email page. I have all the required attachments stored in a local <list>attachment variable called attach_criteria. How do I make a transfer from this attach_criteria to fileAttachments so that I can set up the email attachments to be sent? I tried using the following for-loop:

 

 for(i=0; i < attach_criteria.size(); i++){
            messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();
            efa.setFileName(attach_criteria[i].Name);
            efa.setBody(attach_criteria[i].Body);
            }
            message.setFileAttachments(fileAttachments);

but I get the error:

 

SObject row was retrieved via SOQL without querying the requested field: Attachment.Body

 

Please show me with code how I can pass values from attach_criteria to fileAttachments. Thanks for your time.