Create an Email as a Quick Action

Launch the email composer with pre-populated content from a button in your custom component. Use the lightning-navigation and lightning-page-reference-utils components to create a QuickAction (Global) Send Email action, which opens an email draft with pre-populated field values.

In your component’s HTML file, define the navigation services with lightning-navigation, the page reference utilities with lightning-page-reference-utils, and the action button with lightning-button.

In this example, the handleClick function triggers on click, and it pre-populates the email composer with Subject and Body text.

To include default text in the email composer, use the encodeDefaultFieldValues function. Add the result to the defaultFieldValues attribute in the page reference you pass into the fieldOverride payload. To populate the email with input from your component, pass the field values into the encodeDefaultFieldValues function.

Ensure that the fields you specify in the encodeDefaultFieldValues function aren’t Read-Only in the Send Email global action’s layout. In this example, if the HTML Body and Subject fields are Read-Only, the email draft doesn’t include pre-populated text for those fields.

Add a button that triggers your event handler in your HTML file.

Then add your event handler.