SharePoint列表Email按钮JSON代码:自动填充邮件主题可行性问询
完全可行,修改方法如下
你只需要利用mailto协议的subject参数,就能在点击按钮时自动填充邮件主题。具体修改现有JSON里的href属性即可:
原代码中的href是:
"href": "='mailto:' + [$Kontakt.email]"
假设存储邮件主题的字段内部名称是EmailSubject(请替换成你实际使用的字段内部名称),修改后的href应该写成:
"href": "='mailto:' + [$Kontakt.email] + '?subject=' + encodeURIComponent([$EmailSubject])"
用encodeURIComponent是为了处理主题里的空格、特殊字符,避免mailto链接失效。
修改后的完整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=' + encodeURIComponent([$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" } } ] } ] }
注意:务必将代码里的[$EmailSubject]替换为你实际存储邮件主题的字段内部名称——这个名称可以在SharePoint列表设置的字段详情页面找到。
内容的提问来源于stack exchange,提问作者Elvedin Odžini
相关产品推荐
相关产品推荐

