Loading

Error 'Insufficient Access Rights' When Deleting EmailMessage Records in Salesforce Enhanced Email

Date de publication: May 20, 2026
Description

Salesforce organizations with Enhanced Email enabled may notice high storage usage for Tasks and EmailMessage objects when viewing Storage Usage under Monitor Data and Storage Resources. Administrators who attempt to delete EmailMessage records to free up storage may encounter the following error:
'Insufficient Access Rights On Object Id: INSUFFICIENT_ACCESS_OR_READONLY'
This article explains the delete behaviors for EmailMessage records in orgs with Enhanced Email enabled and provides a step-by-step process for safely removing them using Data Loader.

Résolution

EmailMessage Delete Behaviors

  • Deleting an EmailMessage record automatically deletes the associated Task. However, deleting a Task does not delete the associated EmailMessage. See Considerations for Using Enhanced Email for more details.
    • Note: If your organization has Email-to-Case set up, deleting an EmailMessage related to a Case record does not automatically delete the associated Task.
  • Deleting EmailMessage records before their related Tasks is the recommended best practice. Task records are then deleted without the need to contact Support.
  • Deleting an EmailMessage's related Task may result in EmailMessage records persisting in an orphaned state (where ActivityId is NULL and ParentId is NULL).
  • Administrators with "Modify All Data" permission can delete EmailMessage records as long as they are not in an orphaned state.
    • Note: If an EmailMessage record is in an orphaned state, only the creator of that record has permission to delete it. Administrators with "Modify All Data" may not see the delete option in the user interface. Attempting to delete via the API returns the error: 'Insufficient Access Rights On Object Id: INSUFFICIENT_ACCESS_OR_READONLY'
  • Deleting related Contact or Lead records in the Name (WhoId) field on the EmailMessage's related Task does not cascade or automatically delete the EmailMessage record.
  • Deleting related Case records does cascade and automatically delete any related EmailMessage records and their related Task records. For example, if an EmailMessage record has a Case in its "Parent Case" field, deleting that Case also deletes the EmailMessage and its associated Activity or Task record.

Steps to Delete Contacts or Leads and Associated EmailMessage Records

Always back up your data before performing any data manipulation. Use Export Backup Data or Export Data in Data Loader and select all fields on the appropriate object.

  1. Identify which Contact or Lead records to delete. Create a CSV file with those record IDs.
  2. Use Data Loader to delete the Contact or Lead records using the CSV from Step 1.
  3. Export any resulting orphaned Tasks (where WhoId is NULL and WhatId is NULL) as a backup. Create a CSV file with orphaned Task record IDs.
    1. Example Data Loader query: Select Id, WhoId, WhatId, Subject, Status FROM Task WHERE WhoId = '' AND WhatId = ''
  4. If working with a small subset of orphaned Task records, build a query using the Task IDs from Step 3 to return orphaned EmailMessage records. Export these as a backup and create a CSV of EmailMessage record IDs.
    1. Example Data Loader query: SELECT Id FROM EmailMessage WHERE ActivityId IN ('TaskId1', 'TaskId2', 'TaskId3')
    2. Replace TaskId1, TaskId2, TaskId3 with the orphaned Task record IDs from Step 3. Add additional fields as needed for backup.
    3. Note: If there are too many orphaned Task IDs to build the query, skip to Step 6.
  5. Use Data Loader to delete orphaned EmailMessage records using the CSV from Step 4. This also cascades and deletes their related orphaned Task records.
  6. Use Data Loader to delete Tasks using the CSV from Step 3.
  7. Export orphaned EmailMessages (where ActivityId is NULL and ParentId is NULL) as a backup before proceeding.
    1. Example Data Loader query: Select Id, ParentId, ActivityId, CreatedDate, TextBody FROM EmailMessage WHERE ActivityId = '' AND ParentId = ''

Log a Case with Salesforce Support

Since it may not be scalable to ask each orphaned EmailMessage record owner to delete their own records, orphaned EmailMessage records may be removed in bulk by contacting Salesforce Support.
Please ask Support to reference article number 000384885 when logging the Case and include permission for Support to run the necessary process to manually clear and purge all orphaned EmailMessage records.
Note: Deleting a subset of orphaned EmailMessage records is not possible. The process deletes all orphaned EmailMessage records — there are no exceptions.

Numéro d’article de la base de connaissances

000384885

 
Chargement
Salesforce Help | Article