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 

Zip file of all attachments

Hi All,


        I need to get the zip file of all attachments from case object where case status is closed.I tried using export wizard but no hope. Any help of how to extract zip file of all attachments.



Best Answer chosen by Admin (Salesforce Developers) 

I think I usually use the weekly export. It contains all attachments.

All Answers


I think I usually use the weekly export. It contains all attachments.

This was selected as the best answer

Thanks Jeremyy.Do you know any other way to extract attachments of just closed cases.


It's possible to do via the api, so there may be a 3rd party tool that does it. The data loader can do it, but instead of creating a file for each attachment, you get a typical CSV, but the Body column contains the attachment's data, base64 encoded. You'd have to do the work to pull out that data, decode it, and do something with it.


Just came across this python script I wrote a while back. I think I used it successfully, but don't really remember, so no guarantees.


It will take an attachment csv export from the data loader and do exactly what I explained before – for each record, decode the data and write it to a new file.


If you create a text file called, and you have a csv file called attachments.csv, execute the script like this:


python attachments.csv


#! /usr/bin/env python

import sys
import csv
import base64
import io


if len(sys.argv) < 2:
	raise RuntimeException('File name should be passed as argument')
reader = csv.DictReader(open(sys.argv[1]), delimiter=',', quotechar='"')
for row in reader:
	f =['NAME'], 'wb')

Thanks jeremyy. Can you please tell me how to run python script.


To run the script, the command is:


python attachments.csv


You must have python 2.x installed.