1

I have a SharePoint online list and I want to include a column so users can click to send an email to follow up about a list item they're interested in, and would prefer not to use Power Automate if I can avoid it for this simple task.

I have the basic functionality working.

The column displays the email icon with a mailto link:

column with icon

When I click on the link, an email opens up and populates the "to" field with a static value I've defined, and I can put text into the subject and body fields:

email message

The problem is that I want to reference the item details in the subject line and body. Obviously, my attempts to include the Title field in the subject and the value of the category field in the body aren't working. What am I doing wrong?

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "children": [
    {
      "elmType": "span",
      "style": {
        "padding": "12px"
      },
      "txtContent": "email"
    },
    {
      "elmType": "a",
      "attributes": {
        "iconName": "Mail",
        "class": "sp-field-quickActions",
        "href": {
          "operator": "+",
          "operands": [
            "mailto:",
            "[email protected]",
            "?subject=Interest in donation [$Title]&body=text goes here<br>[$Category.value]"
          ]
        }
      }
    }
  ]
}

1 Answer 1

1

You are very close! When using the AST syntax (operators and operands) you'll need to make each string you want to add as a separate operand. So your format can be rewritten like this:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "children": [
    {
      "elmType": "span",
      "style": {
        "padding": "12px"
      },
      "txtContent": "email"
    },
    {
      "elmType": "a",
      "attributes": {
        "iconName": "Mail",
        "class": "sp-field-quickActions",
        "href": {
          "operator": "+",
          "operands": [
            "mailto:",
            "[email protected]",
            "?subject=Interest in donation ",
            "[$Title]",
            "&body=text goes here<br>",
            "[$Category.value]"
          ]
        }
      }
    }
  ]
}

There's a sample that might also be helpful in showing how to do this using the Excel Style expressions: https://github.com/pnp/List-Formatting/tree/master/column-samples/generic-mailto-button

2
  • Awesome - that did the trick... thanks! I think I still need to put my breaks in differently so they don't just show up as text, but I should be able to take it from here!
    – Darryl
    Feb 18, 2022 at 23:01
  • Discovered that <br> doesn't work for a line break. To have a break between "text goes here" and my category, I need to have the JSON like this: "&body=text goes here", "\r\n", "[$DonationCategoryF]"
    – Darryl
    Feb 23, 2022 at 21:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.