Working with Attachments
In Salesforce, you link attachment files to specific records, such as contacts, events, or accounts. Import, export, and delete attachments in Dataloader from MuleSoft the same way you work with any other Salesforce object, with a few extra steps to handle the file content.
When you import attachments, map three required fields: File Name, Parent ID, and Body. The Parent ID connects each attachment to an existing Salesforce record, and Body points to the file inside a ZIP archive.
Each attachment supports up to 25 MB. The Salesforce Knowledge and Documents tab limits files to 5 MB. The maximum email attachment size is 10 MB.
Because of platform limits, you can process up to 2,000 attachments per run. Larger batches can hit the two-hour task timeout and expire.
To import attachments with Dataloader from MuleSoft, follow these steps.
-
Compress all attachments into a ZIP file that contains all files to upload.
-
Get the IDs of related Salesforce records. Each attachment must be linked to a Salesforce record (for example, a contact or an event) that already exists before you can import it. To get the record IDs, run an Export Data Task and include the ID field.
-
Build a CSV file with the required fields. Your CSV file requires three fields:
- File Name: The file name as you want it to appear in Salesforce.
- Parent ID: The ID of the Salesforce record you link each attachment to.
- Body: The file path of the file as it exists inside the ZIP file from step 1.
When opened as a spreadsheet, your CSV file should resemble this table:
File Name Parent ID Body Attachment1newName.png 00000001 Attachment1.png Attachment2newName.png 00000002 Attachment2.png Use the same column headers in your CSV file as in this example so the required fields map correctly in the import task.
-
Click New Task then click Import.

-
Configure connection, operation, and object:
-
Select the CSV and ZIP files you created. Upload two files: a ZIP file with the attachments and a CSV file that references each attachment. You can select these files from your disk or from cloud storage, such as Dropbox, Box, or FTP/SFTP servers.
-
Map the fields, then click Save or Save and Run (Save and Run Your Task).
Export attachments from Salesforce the same way you export any other object, with the addition of the Body field to retrieve the attachment files.
Follow the standard export steps in Export Data from Salesforce and select the Attachment object in the first step.
Select the Body field in the second step. All other fields are metadata about the attachment. The Body field contains the attachment file itself.

After the task runs, open Task Manager and click the link for the export task to download all attachments as a compressed ZIP file.
Delete attachments from Salesforce by running a delete task with a CSV file that contains the attachment IDs.
Delete attachments using the same flow as any other object. Upload a CSV file with the IDs of the attachments to delete.
In the delete task flow, select Attachment as the object, upload your CSV file, and run the task.
