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
YonathanYonathan 

Email attachment Compression

Hi all,

 

Here is my code :

 

public void sendEmail(string attach,string body) { Blob fileBody = Blob.valueOf(attach); Messaging.EmailFileAttachment[] fileAttachments = new Messaging.EmailFileAttachment[1]; Messaging.EmailFileAttachment fileAttachment = new Messaging.EmailFileAttachment(); fileAttachment.setBody(fileBody); fileAttachment.setFileName('users.xml'); fileAttachments[0] = fileAttachment; Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); ... mail.setPlainTextBody(body); mail.setFileAttachments(fileAttachments); Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); }

 

 

Is it possible to programmatically create and compress a file to be attached in email ?