我有一个用于错误处理的天蓝色逻辑应用程序,它从服务总线主题读取数据。这个想法很简单,我想向适当的团队发送一封电子邮件,通知他们失败并附加失败的 JSON 数据。
我的问题是,通过 Outlook 步骤“发送电子邮件 v2”发送时,JSON 格式完全丢失
我尝试创建一个步骤来替换 我的 JSON 字符串中的字符以及用于换行的 html 代码,使用 json 函数组合变量,并使用 compose 创建我自己的 HTML 并将其放入电子邮件正文中。
我想要做的就是让电子邮件保持与撰写步骤的输出中出现的格式相同的格式,但它总是回来时都是混乱的,并且在 Outlook 中更难以阅读。
我正在寻找的东西可以实现吗?这是我的逻辑应用程序代码。
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Compose": {
"inputs": "@{triggerBody()?['contentData']} ",
"runAfter": {},
"type": "Compose"
},
"Send_an_email_(V2)": {
"inputs": {
"body": {
"Body": "<p>Hello,<br><br>An error was detected from! Please review the below details and investigate the error.<br><br>Here is the error message<br>@{triggerBody()?['label']}<br><br>Here is the data that was passed<br>@{outputs('Compose')}<br><br>Please reach out to the IT department with a helpdesk ticket if further action is required.</p>",
"Importance": "Normal",
"Subject": "Error detected from our API",
"To": "[email protected]"
},
"host": {
"connection": {
"referenceName": "office365"
}
},
"method": "post",
"path": "/v2/Mail"
},
"runAfter": {
"Compose": [
"SUCCEEDED"
]
},
"type": "ApiConnection"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"triggers": {
"When_messages_are_available_in_a_topic": {
"inputs": {
"parameters": {
"isSessionsEnabled": false,
"subscriptionName": "sbs-api",
"topicName": "sbt-error-handling"
},
"serviceProviderConfiguration": {
"connectionName": "serviceBus",
"operationId": "receiveTopicMessages",
"serviceProviderId": "/serviceProviders/serviceBus"
}
},
"splitOn": "@triggerOutputs()?['body']",
"type": "ServiceProvider"
}
}
},
"kind": "Stateful"
}
感谢您的帮助/建议!
我能弄清楚!我的错误是从 azure 逻辑应用程序的角度来看这个问题,而不是 HTML 渲染的角度。发送电子邮件 v2 方法默认使用 HTML 渲染来发送电子邮件。
为了使输出正确渲染,我必须用
标签将其包围。这让浏览器(天蓝色)知道这是预先格式化的文本,无需更正它。它看起来像这样,并且完全按照我的预期进行渲染
<pre>@{outputs('Compose')}</pre>