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

Automatically Downloading attachments from opportunity

Hello All,


Good Time,


I would like to download attachments of Opportunity automatically, could you please suggest how do you want me to procced.


is there any tool which is avaliable in or do i need to write SOQL if yes then could you please provide me some solution for this.


Thanks in advance




HI Satish, 


This mostly depends on what tools/utilities you use to extract. The SOQL for Attachment sObject will always return one row at a time if Body field is included in the query. This is enforced to conserver resources and prevent overbearing SOQL scripts.


Approach #1, if queryMore is not available: Issue a SOQL without Body field to enumerate all attachments, then issue one SOQL per attachment ID to retrieve Body

Approach #2: Issue a SOQL to retrieve all needed attachments then loop using queryMore to get them one at a time.

Approach #3: If you can "freeze" the SF environment and just want to take snapshot of the system to pre-load a different one to be used going forward you can use "data exports". In setup menu, in data management there is an export data command, make sure you click "Include in export" to include all binary data. After due process it will give you a complete data backup you can crunch offline.


Btw, body is base64 encoded, you'll need to decode it to get the actual binary




Hello Ashi,


Thanks for your reply.


i tried to download attachements while using Fileexporter tool, and exported attachments folder has been creatd along with Base64. file type. could you please let me know how do we download original file attachments.


and also am finding below error while running the vbs files


Line: 26
Char: 2
Error: File no found
code: 800A0035
Source: Microsoft VBScript runtime error


Line: 26
Char: 2
Error: File not found
Code: 800A0035
Source: Microsoft VBScript runtime error



please let us know if you need more details.




Sathish R



Here is the way to view all your attachment through soql... 



When u click view in visualforce page you can download your attachment...


If you found this answer helpful to you... Please accept this as a Solution and  give kudos by clicking on the star icon.


Thanks and Regards,

Arunkumar.R | Salesforce Certified Developer


Hi Satish, 



Please see the links for the VB Error,






Thanks ashish,


i will make the neccessary changes



Hi Satish, 


The blog is Written by Arun Kumar who has posted this code for us.




Hello Arun

Thanks for replying for my query.
i have gone through the below blog and could able to see all the attachemnts in single page as of now its great but is there any possibility to download in particular page...could you please help me out

appreciate your help.

Thanks & Regards,
Sathish R
Sonam MeshramSonam Meshram
Hello all,

I came across the newly developed app in AppExchange where you can download almost any Attachment or File under one or multiple records all at once.

They do support download of Static Resource & Documents, email messages too.

Please have a look: