SOLVED

Sharepoint 365 - Adding clickable email to list

Copper Contributor

Hi Guys - is there a way of adding a selectable/dynamic email address to a list where that address isn't part of the same domain as SharePoint i.e. the email address of a project partner / client?


Aware I can add in a text field, but then the email address isn't 'clickable'?

Any suggestions appreciated.

12 Replies

@jacobite You can use column formatting to create a clickable link in list view. Check this https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/column-formatting#add-an-a... 

best response confirmed by jacobite (Copper Contributor)
Solution

@jacobite Yes, it is possible to convert the text field to clickable text in list view using column formatting. Follow below steps:

  1. Create a single line of text field in your list to enter email address.
  2. From list view, select column name header, select "Column settings" and then select "Format this column". ganeshsanap_0-1659592177288.png
  3. Click on "Advanced mode" from right side panel.
  4. Copy-paste below JSON on textbox by removing existing JSON and click Save

 

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "a",
  "txtContent": "@currentField",
  "attributes": {
    "href": "='mailto:' + @currentField"
  }
}

 

Output

ganeshsanap_1-1659592399979.png

DocumentationSharePoint column formatting 


Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

@ganeshsanap
many thanks for taking the time to contribute such a helpful response - many thanks! 🙂

@jacobite You're welcome, happy to help. Glad it worked for you!


Please consider giving a Like if my post helped you in any way.

@ganeshsanap This is helpful, but now, if the user clicks on the same field and it is empty, Outlook opens up. How do I make it so that it only adds mailto: on fields that are not blank?

Found the solution for anyone else interested.

I wanted to make a text field as a clickable mailto link, but only if it was not blank. Here's the code I used (under List Settings>Edit Column>Column Formatting)

{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "a",
"txtContent": "=if(@currentField == '', '','Send E-Mail')",
"attributes": {
"href": "=if(@currentField == '', '','mailto:' + @currentField)"
}
}

@markm4g You can also use below JSON instead which shows/hides the anchor element based on the value of current column: 

 

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "a",
  "txtContent": "@currentField",
  "attributes": {
    "href": "='mailto:' + @currentField"
  },
  "style": {
    "display": "=if(@currentField, 'block', 'none')"
  }
}

 

OR 

 

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "a",
  "txtContent": "@currentField",
  "attributes": {
    "href": "='mailto:' + @currentField"
  },
  "style": {
    "display": "=if(@currentField != '', 'block', 'none')"
  }
}

 

Related readSharePoint JSON formatting: Check if column is blank/empty 


Please consider giving a Like if my post helped you in any way.

@ganeshsanap
That was helpful, thank you.
In SharePoint column formatting, can you directly embed images in the email body using HTML content within a mailto link, or does The mailto link only supports plain text content and not support HTML formatting or embedded images?

@bryanfrumkin47 You cannot pass the HTML, images, hyperlinks, or attachments using mailto protocol as it only accepts string/text values as input.

 

Check my answers at:

  1. Is there any way to pass html content while triggering mailto: option? 
  2. JSON formatting: make some words inside body text of email bold 
  3. How do I pass HTML table inside mailto in anchor tag? 
  4. SharePoint JSON email attachment 
  5. SharePoint JSON hyperlink text in email 

Please consider giving a Like if my post helped you in any way.

@ganeshsanap

Your solution is very useful.  I have multiple persons in my Assigned to column and when i click on the link the email pops up with each person's email in the Send to: field.  I need, if possible, to have each person receive an individual email as part of the Approval process. 

@GMack2378 

 

In case of multiple selection person column, you will have to generate the mailto link for each user using "forEach" and click on each link manually to send email to respective user.

 

Check this JSON sample for your requirements: Multi-Person Mail To Link 

 

Output

ganeshsanap_0-1706783649880.png


Please consider giving a Like if my post helped you in any way.

1 best response

Accepted Solutions
best response confirmed by jacobite (Copper Contributor)
Solution

@jacobite Yes, it is possible to convert the text field to clickable text in list view using column formatting. Follow below steps:

  1. Create a single line of text field in your list to enter email address.
  2. From list view, select column name header, select "Column settings" and then select "Format this column". ganeshsanap_0-1659592177288.png
  3. Click on "Advanced mode" from right side panel.
  4. Copy-paste below JSON on textbox by removing existing JSON and click Save

 

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "a",
  "txtContent": "@currentField",
  "attributes": {
    "href": "='mailto:' + @currentField"
  }
}

 

Output

ganeshsanap_1-1659592399979.png

DocumentationSharePoint column formatting 


Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

View solution in original post