+ Start a Discussion

how to generate a report of attachments within emails


Hope any one can help me with this.

I wish to generate a report of attachments within emails( from Case Emails).  Is there a way to do this and if so how is it done.


Thanks a ton in advance!






Hi Kumar,

                  If you bind the attachments with email through apex code then you can use EmailFileAttachment object. The EmailFileAttachment object is used in the SingleEmailMessage object to specify attachments passed in as part of the request.

Below is the sample code to help you in resolving the issue faced by you:-


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

      String[] toAddresses = new String[]{'info@salesforce.com'};

           email.setSubject( subject );



           email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa});

           Messaging.SendEmailResult [] r =Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});


Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.



Thank you very much Ispita Saha.