Back to column formats
Column formattingSharePoint 2019SharePoint Online

Person Mail To Link

You can use column formatting to render quick action links next to fields. This sample, intended for a person field, renders two elements inside the parent `<div />` element:

Person Mail To Link formatting preview
Sample preview · View original image

Copy. Apply. Make it yours.

Get this format

2 definitions

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": "div",
  "children": [
    {
      "elmType": "span",
      "style": {
        "padding-right": "8px"
      },
      "txtContent": "@currentField.title"
    },
    {
      "elmType": "a",
      "attributes": {
        "iconName": "Mail",
        "class": "sp-field-quickActions",
        "href": "='mailto:' + @currentField.email + '?subject=Task status&body=Hey, how is your task coming along?.\r\n---\r\n' + @currentField.title + '\r\nClick this link for more info. http://contoso.sharepoint.com/sites/ConferencePrep/Tasks/Prep/DispForm.aspx?ID=' + [$ID]"
      }
    }
  ]
}

From the contributor

How to use this sample

Summary

You can use column formatting to render quick action links next to fields. This sample, intended for a person field, renders two elements inside the parent <div /> element:

  • A <span /> element that contains the person’s display name.
  • An <a /> element that opens a mailto: link that creates an email with a subject and body populated dynamically via item metadata. The <a /> element is styled using the sp-field-quickActions class and uses the iconName attribute to make it a clickable email icon.

screenshot of the sample

View requirements

  • This format expects to be applied to a Person column

Sample

Solution Author(s)
person-mailto.json SharePoint Team

Version history

Version Date Comments
1.0 November 2, 2017 Initial release
1.1 August 18, 2018 Changed from generic-action-button to person-mailto and switched to Excel-style expressions

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

This sample is also covered in the main documentation around Column Formatting

A similar wizard is also included in the Column Formatter webpart that allows full customization.

An additional version using Abstract Tree Syntax (AST) is also provided for environments where the Excel-style expressions are not supported.