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
Tom Callahan 1Tom Callahan 1 

SendEmail failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id:

We have a Salesforce org that uses a Salesforce Community. Is there a known security limitation on a Community User executing the Messaging Class SendEmail method in Apex? We are attempting to email a contact via Apex as the Community User.

Any user other than the community user can execute the SendEmail function as found in Apex. 

Please note, the Community user has a special profile that is only accessible via Salesforce Sites. The profile has the needed Apex Access and the following System Permissions are enabled...
  • Mass Email
  • Send Email
Please advise.
Suraj MakandarSuraj Makandar
Hi Tom,

This is not because of any security limitation, you are getting this error as in your code you are accessing the object/record Id to which the community user does not have access.

Please provide the requried permissios of all the object records you are accessing/using in your code while sending the email.

Hope this helps!

Note: Please mark it as best answer if the information is informative.