• Pedro I Dal Col
  • 10 Points
  • Member since 2015
  • Zippex

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 18
Hi Friends,
         My requirement is , I need to send a email with the document in the attachment related list, as a zip file.  How to add attachment by zippex class,

                       Many thanks in Advance
hi All,
I want to download a zip file from url and unzip that file.I got some code but that is not working.
Need some new code in apex to do this.
Thanks in advance
I have one static resource zip file, which has N number of Images. So I don't know the exact number of images are present in zip file.
I just want loop through all the images in zip file. How can I achieve this?. Any help is appreciable.
My VFP page is,

<apex:page Controller="repeatCon">
<body style="font-size:10pt; font-family:sans-serif">
            <td style="font-family:'Segoe UI', Tahoma, sans-serif;">
                <apex:repeat value="{!imageList}" var="img">
                    <td><apex:image url="{!URLFOR($Resource.MinionsDemo,img)}" height="200" width="200" /><br/></td>

and my controller class is,
public class repeatCon {
    public List<string> getimageList(){
        List<String> imgstr = new List<String>();
        for(integer i = 1; i <= zipfileimagesize; i++){
    return imgstr;
in the loop how do I give the size of images present in zip file
In my application, i am sending an HttpRequest to an external server to get a zip file, and once it's done i get the response as Blob, but i don't know how to process the Blob to extract some files from it.
This is the code:
HttpRequest request = new HttpRequest();

 /* Here i set the Endpoint, body, and method attributes*/

Http http = new Http();                
HttpResponse response = http.send(request);

 Blob file = response.getBodyAsBlob();

/*Here i should process the Blob (which is a zip file) to extract my files*/
Help please.. !!
Anyone help me. How i can unzip file in apex class?? Thanks 
Hi folks,
      Can anyone tell me how to create a zip file in salesforce via apex?
I have seen the below link but it doesnt work for me.

Please someone give me the working code sinppet for creating zipfile.

Thanks in advance
I have a requirement from a client to process an email via Email Services.  Unfortunately the attachment is a zip XML file.  Is there a way to unzip a file or read the file within the zip file using APEX code?

     How to fetch content of Word file in string. Because now I am getting all content in Blob but I am not able to fetch it in string. 
    I can fetch all content of text file but the same code is not working for word or excel. I tried conversion code from blob to string but it is not working.

    I also tried to encode and decode the content of file,but it is also not working. As encoded file dosent exactly converts into original contents after decode.

 Basically I want to read the content of all MSoffice files posted on chatter.

Thanks in advance.

It is possible an apex class to create a CSV file and after to zip the CSV file into a zip file?

I read many forums but not found answers.

Thank you,
I have an Apex class that generates a CSV file.

global class AAAExporterCSV implements System.Schedulable {
global void execute(SchedulableContext sc) {
List<case> acclist = [Select casenumber,subject, accountid from case where closeddate=TODAY];
string header = 'Id, Subject,Account, '+'\n';
string finalstr = header ;
for(case a: acclist)
   string recordString = a.casenumber + ',' + a.subject+ ',' + a.accountid +'\n';
   finalstr = finalstr + recordString;
Messaging.EmailFileAttachment csvAttc = new Messaging.EmailFileAttachment();
blob csvBlob = Blob.valueOf(finalstr);
string csvname= 'cases.csv';
Messaging.SingleEmailMessage email =new Messaging.SingleEmailMessage();
String[] toAddresses = new list<string> {'v.veve@veve.com'};
String subject = 'Report CSV';
email.setToAddresses( toAddresses );
email.setPlainTextBody('The Merchandise report is attached here.');
email.setFileAttachments(new Messaging.EmailFileAttachment[]{csvAttc});
Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});

I wonder how do I put this CSV (cases.csv) within a ZIP and to send an email.
It is possible to do in the same class?

It's correct: ... where closeddate=TODAY ???
Thank you,
Please suggest how can I read a zip attachment from the VF page. The attachment consists of some text files. Currently I am reading it via zip.js library but it gives a cross domain accessibility error since the attachments are in a different sub domain.

Please suggess a way out!!

I want to create ".Zip" file by APEX which can include other files like .jpg,.txt etc...



  • August 22, 2012
  • Like
  • 0



I saw several posts asking the same question. Is there a way to unzip a file in Apex in the latest release?


I could see that the best solution would be to use an external app, but I think this could be a risk for several reasons. I was also thinking about a JavaScript solution, but I'm not sure if this will work.


I would really appreciate any idea that I could follow to finish the process and make our customer happy.



In account object, I have attached a word document in Notes and Attachement RelatedList. Through apex code, I want to fetch the body text of this word document attached. For this, Apex code is:


Account acc = [select Name from Account LIMIT 1];

Attachment att = [Select name,ContentType,body,ParentId,Description from Attachment where ParentId =: acc.Id];


// Get body of the attachment in Blob variable and converting it to string

Blob bodyBlob = att.body;

String bodyStr = bodyBlob.toString();


But the above code generates String Exception which says: 'BLOB is not a valid UTF-8 string'

The above code works fine for attachments which have .rtf extension.

Is it possible to get the content of the body of any Word (.doc) attachment in Apex? Please suggest some workaround.



I need to invoke a 3rd Party webservice that then returns to me the location of a Zip'd file from within which I need to extract the CSVs for processing.


Is there any suggested pattern for doing this? Would my only option be to transfer the Zip file to an intermediate server for unzipping, and then invoke a webservice hosted on that server tgo retrieve the contained CSVs? Thanks.



Hi I have a question which I'm not 100% is possible in Salesforce but will welcome any suggestions / ideas. I have an APEX class which creates multiple licence keys and has dual functionality, it will either allow the user to email them as part of an email body or create the licenses as a txt file attachment to an outbound email. Now the issue is the text file needs to be enclosed within a zip file due to different mail clients unable to process the .lic extension. Is there any mechanism which will let me wrap a txt file into a zip file as part of an attachment ? Been wracking my brain for ages on this. Any assistance would be welcome even if its not possible.

  • October 01, 2010
  • Like
  • 0

Is there anyway to unzip a file in Apex?