+ Start a Discussion

Getting Exception INVALID_SESSION_ID: This session is not valid for use with the API: []: on Messaging.sendMail


I am trying to send mail when a Case is updated. I have created a trigger for that. It works fine when i update the Case from Sandbox. But when i login to Community with "Customer Community User" profile. I get this INVALID_SESSION_ID. Completed Error Message Is : 
Apex trigger EmailTest caused an unexpected exception, contact your administrator: EmailTest: execution of BeforeUpdate caused by: System.EmailException: SendEmail failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, common.apex.runtime.impl.ExecutionException: INVALID_SESSION_ID: This session is not valid for use with the API: []: Trigger.EmailTest: line 11, column 1.

Is it to do something with "Enable clickjack protection for non-setup Salesforce pages" option on Session Settings Page.
Can anyone please provide me with proper details for the issue and how i can resolve it.

PrasanntaPrasannta (Salesforce Developers) 
Please check whether the community user has access to that object on which you written the trigger.
You can grant access to Customer Communities users to a limited subset of standard objects and all custom objects using Sharing Sets and Sharing Groups. Customer Communities users do not have access to the full sharing model but you can grant access using sharing sets and groups based on a contact or account lookup from Case.

Hope this information helps.