Back to column formats
Column formattingSharePoint Online

MailTo Button

This sample demonstrates making a mailto link (opens email with prepopulated values) button that references a different field.

MailTo Button formatting preview
Sample preview · View original image

Copy. Apply. Make it yours.

Get this format

1 definition

Review the requirements below, then paste this JSON into the matching formatting panel. Show me where.

Use your list's internal column names and replace any tenant-specific URLs or flow IDs. Formatting is presentation, not a way to secure data.

Column formatting
Download JSON
{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "a",
  "attributes": {
    "href": "='mailto:' + [$Commander.email] + '?subject=' + [$Title] + '&body=Dearest ' + [$Commander.title] + ',\r\n\r\nPlease assist me with details on the ' + [$Title] + '.'",
    "target": "_blank",
    "class": "ms-fontColor-themePrimary ms-fontColor-themeDark--hover",
    "title": "Email the Commander"
  },
  "style": {
    "border": "none",
    "background-color": "transparent",
    "cursor": "pointer",
    "text-decoration": "none",
    "outline": "none"
  },
  "children": [
    {
      "elmType": "span",
      "attributes": {
        "iconName": "Mail",
        "class": "ms-font-xxl"
      }
    }
  ]
}

From the contributor

How to use this sample

Summary

This sample demonstrates making a mailto link (opens email with prepopulated values) button that references a different field.

screenshot of the sample

View requirements

  • This format can be applied to any column type (its value is ignored)
  • To apply directly to a person column, just replace all the [$Commander] calls with @currentField

Tip - You can apply these formats to a Calculated Column with a formula of ="". This prevents the fields from being part of your edit/new forms.

Sample

Solution Author(s)
generic-mailto-button.json Chris Kent

Version history

Version Date Comments
1.0 May 27, 2021 Initial release

Disclaimer

THIS CODE IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.


Additional notes

  • The person-mailto demonstrates a similar technique but is applied directly to a person field