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
Brian Broughton 6Brian Broughton 6 

Sending Email using a Visualforce Template via a Platform Event

Hello,

We are receiving the following error when attempting to send an email via a platform event using a Visualforce template:

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

We have narrowed this problem down to a VF Component that the template references. If we remove the component, the above error goes away. However, even though there is no error, none of the data fields outside of the removed component show up in the email body - only the static text does.

If we send this same email, using the same data, via Apex code, it works fine. We have also had success sending other emails via Platform Events without issue with the difference being that they use a regular template. 

Does anyone know if we should be able to send VF based emails via a Platform Event trigger? Or is this a limitation? 

Thank you,
Brian