To create a report ( CSV file ) off a list of attachment you can use the dev console
think about what kind of info you need and create your own csv file ( header) String csv = 'Account id,Account Name,Attachment Id,Attachment Name\n';
List<Attachment> att=[select id,parentid,parent.type,parent.name,name,ownerid from Attachment where parent.type =:'Account'];
String csv = 'Account id,Account Name,Attachment Id,Attachment Name\n';
for(Attachment a:att){
csv+=a.parentid+','+a.parent.name+','+a.id+','+a.name+'\n';
}
Document doc = new Document(
FolderId = UserInfo.getUserId(), // "My Personal Documents" folder
Name = 'ACC_attachments1',
Body = Blob.valueOf(csv),
ContentType = 'text/plain',
Type = 'csv'
);
insert doc;
This does not export the attachments, but it will provide a list with id's which then can be used to download it by pre-fix the attachment id with your Instance URL and then /servlet/servlet.FileDownload?file= you can find your repectve URL by navigating to an attachment and right click the view file link copy the url into notepad.
Once you have run this piece of code in the developer console , you need to navigate to your personal documents in salesforce it will show up under the most recent documents right click the view file and select "save as" it will predeifined show as CSV so you can oprn it with excel lie a report
think about what kind of info you need and create your own csv file ( header)
String csv = 'Account id,Account Name,Attachment Id,Attachment Name\n';
List<Attachment> att=[select id,parentid,parent.type,parent.name,name,ownerid from Attachment where parent.type =:'Account']; String csv = 'Account id,Account Name,Attachment Id,Attachment Name\n'; for(Attachment a:att){ csv+=a.parentid+','+a.parent.name+','+a.id+','+a.name+'\n'; } Document doc = new Document( FolderId = UserInfo.getUserId(), // "My Personal Documents" folder Name = 'ACC_attachments1', Body = Blob.valueOf(csv), ContentType = 'text/plain', Type = 'csv' ); insert doc;
This does not export the attachments, but it will provide a list with id's which then can be used to download it
by pre-fix the attachment id with your Instance URL and then
/servlet/servlet.FileDownload?file=
you can find your repectve URL by navigating to an attachment and right click the view file link copy the url into notepad.
Once you have run this piece of code in the developer console ,
you need to navigate to your personal documents in salesforce
it will show up under the most recent documents
right click the view file and select "save as"
it will predeifined show as CSV so you can oprn it with excel lie a report