azure Logic应用程序-在邮件正文中嵌入base64

omqzjyyz  于 2023-02-25  发布在  其他
关注(0)|答案(1)|浏览(94)

我想在逻辑应用程序电子邮件正文中显示以下图像Base64。

{
"image": [
 "data:image/jpeg;base64,/9j/4AAQSkZJRgA..."
 "data:image/jpeg;base64,/9j/4AAQSkZJRgA..."
 "data:image/jpeg;base64,/9j/4AAQSkZJRgA..."
 "data:image/jpeg;base64,/9j/4AAQSkZJRgA..."
]
}

在setVariable 2中-我将添加所有详细信息
对于图像,我使用了items('For_each'),但是当我提交表单时,我只得到了图像。
让我知道,如果任何一个有想法显示在电子邮件中的多个图像。
〈img src=@{项目('For_each')} /〉

<h1 style="text-alig:center">Demo</h1>

<strong><h3>Location</h3></strong>
<hr/>
<strong>Lat:</strong> @{triggerBody()?['latitude']}
<strong>Lon:</strong> @{triggerBody()?['longitude']}
<br />
<br />

<strong><h3>capture On:</h3></strong>
<hr/>
@{triggerBody()?['catpuredon']}
<br />
<br />

<strong><h3>my Car</h3></strong>
<hr/>
@{triggerBody()?['carphoto']}
<br />
<br />

<strong><h3>Car Photos:</h3></strong>
<hr />
<br />
<img src=@{items('For_each')} />

添加校正后的新图像

7cwmlq89

7cwmlq891#

除了@Skin所说的,我已经将每个条目嵌入到<img>标签中,并将其附加到一个字符串变量中,然后将其添加到邮件正文中。

作为一个样本,我已经采取了相同的图像4次,下面是我的邮件中的结果。

下面是我的逻辑应用程序的完整代码视图

{
"image": {
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "For_each": {
                "actions": {
                    "Append_to_string_variable": {
                        "inputs": {
                            "name": "StringVar",
                            "value": "@concat('<img src=',item(),'>')"
                        },
                        "runAfter": {},
                        "type": "AppendToStringVariable"
                    }
                },
                "foreach": "@variables('ArrayVar')",
                "runAfter": {
                    "Initialize_variable_-_Image_String": [
                        "Succeeded"
                    ]
                },
                "type": "Foreach"
            },
            "Initialize_variable_-_Image_String": {
                "inputs": {
                    "variables": [
                        {
                            "name": "StringVar",
                            "type": "string"
                        }
                    ]
                },
                "runAfter": {
                    "Initialize_variable_-_Images_Array": [
                        "Succeeded"
                    ]
                },
                "type": "InitializeVariable"
            },
            "Initialize_variable_-_Images_Array": {
                "inputs": {
                    "variables": [
                        {
                            "name": "ArrayVar",
                            "type": "array",
                            "value": [
                                "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgA...",
                                "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgA...",
                                "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgA...",
                                "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgA..."
                            ]
                        }
                    ]
                },
                "runAfter": {},
                "type": "InitializeVariable"
            },
            "Send_an_email_(V2)": {
                "inputs": {
                    "body": {
                        "Body": "<p>@{variables('StringVar')}</p>",
                        "Importance": "Normal",
                        "Subject": "Images",
                        "To": "xxx"
                    },
                    "host": {
                        "connection": {
                            "name": "@parameters('$connections')['office365']['connectionId']"
                        }
                    },
                    "method": "post",
                    "path": "/v2/Mail"
                },
                "runAfter": {
                    "For_each": [
                        "Succeeded"
                    ]
                },
                "type": "ApiConnection"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {
            "$connections": {
                "defaultValue": {},
                "type": "Object"
            }
        },
        "triggers": {
            "manual": {
                "inputs": {
                    "schema": {}
                },
                "kind": "Http",
                "type": "Request"
            }
        }
    },
    "parameters": {
        "$connections": {
            "value": {
                "office365": {
                    "connectionId": "/subscriptions/xxx/resourceGroups/xxx/providers/Microsoft.Web/connections/office365",
                    "connectionName": "office365",
                    "id": "/subscriptions/xxx/providers/Microsoft.Web/locations/eastus/managedApis/office365"
                }
            }
        }
    }
}
}

相关问题