json SharePoint列表-电子邮件按钮

ff29svar  于 2023-05-19  发布在  其他
关注(0)|答案(2)|浏览(183)

这段代码使outlook窗口自动打开,当我们按下“电子邮件”按钮,并采取已保存在“联系”字段的电子邮件.我们需要完成此代码,以便当我们按下按钮时,它会自动获取保存在另一个字段中的电子邮件的主题。可以使用JSON代码吗?

{
  "_comment": "A button to send an email",
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "a",
  "attributes": {
    "class": "ms-fontColor-black ms-fontColor-white--hover",
    "title": "Send Email",
    "href": "='mailto:' + [$Kontakt.email]",
    "target": "_blank"
  },
  "style": {
    "border": "none",
    "cursor": "pointer",
    "background-color": "transparent"
  },
  "children": [
    {
      "elmType": "div",
      "attributes": {
        "class": "ms-bgColor-greenLight ms-bgColor-green--hover ms-fontColor-black ms-fontColor-white--hover"
      },
      "style": {
        "font-size": "16px",
        "font-family": "arial",
        "border": "1px solid Black",
        "border-radius": "7px",
        "padding": "3px 5px 3px 5px",
        "box-shadow": "2px 2px #999"
      },
      "children": [
        {
          "elmType": "div",
          "attributes": {
            "iconName": "Mail"
          },
          "style": {
            "display": "=if('Mail' != '','inline-block','none')",
            "vertical-align": "middle",
            "padding-right": "5px"
          }       
        },
        {
          "elmType": "div",
          "txtContent": "=if('' != '',' EMAIL',' EMAIL')",
          "style": {
            "display": "inline-block",
            "font-family": "arial",
            "vertical-align": "middle"
          }
        }
      ]
    }
  ]
}
qncylg1j

qncylg1j1#

是的,您可以将其添加到href值中。
尝试以下操作:

"href": "='mailto:' + [$Kontakt.email] + '?subject=' + [$Subject]"

pbgvytdp

pbgvytdp2#

假设您有另一个名为EmailSubject的字段,其列类型为单行文本或多行文本,
您可以在JSON中更改href属性,如下所示:

"href": "='mailto:' + [$Kontakt.email] + '?subject=' + [$EmailSubject]",

其中EmailSubject是列的内部名称。您可以通过遵循本文获得列的确切内部名称:How to find the Internal name of columns in SharePoint Online?
有关更多信息,请查看此Microsoft官方文档:向字段添加电子邮件操作按钮(高级)
查看此文档以了解mailto中支持的属性:How to Create Mailto Links

更新

使用完整的JSON:

{
  "_comment": "A button to send an email",
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "a",
  "attributes": {
    "class": "ms-fontColor-black ms-fontColor-white--hover",
    "title": "Send Email",
    "href": "='mailto:' + [$Kontakt.email] + '?subject=' + [$EmailSubject]",
    "target": "_blank"
  },
  "style": {
    "border": "none",
    "cursor": "pointer",
    "background-color": "transparent"
  },
  "children": [
    {
      "elmType": "div",
      "attributes": {
        "class": "ms-bgColor-greenLight ms-bgColor-green--hover ms-fontColor-black ms-fontColor-white--hover"
      },
      "style": {
        "font-size": "16px",
        "font-family": "arial",
        "border": "1px solid Black",
        "border-radius": "7px",
        "padding": "3px 5px 3px 5px",
        "box-shadow": "2px 2px #999"
      },
      "children": [
        {
          "elmType": "div",
          "attributes": {
            "iconName": "Mail"
          },
          "style": {
            "display": "=if('Mail' != '','inline-block','none')",
            "vertical-align": "middle",
            "padding-right": "5px"
          }       
        },
        {
          "elmType": "div",
          "txtContent": "=if('' != '',' EMAIL',' EMAIL')",
          "style": {
            "display": "inline-block",
            "font-family": "arial",
            "vertical-align": "middle"
          }
        }
      ]
    }
  ]
}

相关问题