Formatted Email

lightning-formatted-email

Displays an email as a hyperlink with the mailto: URL scheme.

For Use In

Lightning Experience, Experience Builder Sites, Salesforce Mobile App, Lightning Out (Beta), Standalone Lightning App, Mobile Offline

A lightning-formatted-email component displays a read-only representation of an email address as a hyperlink using the mailto: URL scheme. Clicking on the email address opens the default mail application for the desktop or mobile device.

This example displays an email address with an email icon. The email address is displayed as the default label.

1<template>
2    <lightning-formatted-email value="hello@example.com">
3    </lightning-formatted-email>
4</template>

This example prevents the display of the email icon.

1<template>
2    <lightning-formatted-email value="hello@example.com" hide-icon>
3    </lightning-formatted-email>
4</template>

Multiple email addresses are supported. The label “Send a group email” is displayed as a hyperlink in this example.

1<template>
2    <lightning-formatted-email
3        value="hello@example.com,email@example.com"
4        label="Send a group email"
5    >
6    </lightning-formatted-email>
7</template>

This example creates an email address with values for cc, subject, and email body. The label is displayed as a hyperlink.

1<template>
2    <lightning-formatted-email
3        value="hello@example.com?cc=email@example.com&subject=My%20subject &body=The%20email%20body"
4        label="Send us your feedback"
5    >
6    </lightning-formatted-email>
7</template>

LWC Recipes 

The LWC Recipes GitHub repository contains code examples for Lightning Web Components that you can test in an org.

For a recipe that uses lightning-formatted-email, see the following components in the LWC Recipes repo.

  • c-nav-to-record
  • c-wire-get-record-user

See Also 

Object Reference for the Salesforce Platform: Field Types

Attributes 

NameDescriptionTypeDefaultRequired
hide-iconIf present, the email icon is hidden and only the email address is displayed.booleanfalse
labelThe text label for the email address.string
tab-indexReserved for internal use. Use tabindex instead to indicate if an element should be focusable. A value of 0 means that the element is focusable and participates in sequential keyboard navigation. A value of -1 means that the element is focusable but does not participate in keyboard navigation.number
valueThe email address that's displayed if a label is not provided.string

Methods 

NameDescriptionArgument NameArgument TypeArgument Description
blurRemoves keyboard focus from the element.
clickSimulates a mouse click on the email address and opens the default email app.
focusSets focus on the element.