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
SV 9SV 9 

Steps to use dataloader to convert email attachments to files.

Need to move all historical email attachments to files.
VinayVinay (Salesforce Developers) 
Hi Sravanthi,

Below are steps.to migrate attachments to Salesforce Files.

1. Export Attachments data using data loader. 
2. Export Attachments files, using data export wizard or File exporter. 
3. Create two fields, ParentId and AttachmentId on ContentVersion object 
  •  ParentId will hold the id of the entity, attachment was linked to. 
  •  AttachmentID (with unique constraint) will hold the id of the attachment from attachment object.
4. Create a CSV, ContentVersion_upload.csv, for ContentVersion with the following fields
  • Attachment_id (AttachmentId from file exported in step-1)
  • ISDELETED 
  •  PARENTID (Entity Id of the object, from file exported in step 1) 
  • Versiondata (local file path) 
  • PathOnClient (local file path) 
  • Title (title of the file) 
  • OWNERID 
  • DESCRIPTION
5. Upload (Insert) ContentVersion.csv into ContentVersion object. 
6. Export ContentVersion data uploaded in step-5 using data loader. 
7. Create another CSV for ContentDocumentLink (and update ContentDocumentID andParentEntityId, from the ContentVersion file exported in step-5) with the following fields: 
  • CONTENTDOCUMENTID (ContentDocumentId from file exported in step-6) 
  • LINKEDENTITYID (ParentId from file exported in step-6) 
  • SHARETYPE 
  • VISIBILITY
8. Upload (Insert) ContentDocumentLink.

Hope above information was helpful.

Please mark as Best Answer so that it can help others in the future.

Thanks,
Vinay Kumar
SV 9SV 9
Thnak you.
VinayVinay (Salesforce Developers) 
Please mark as Best Answer if above information was helpful so that it can help others in the future.

Thanks,
Vinay Kumar