I want to display the following image Base64 inside the logic Apps email body.
{
"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..."
]
}
Inside the setVariable 2 - I'm adding all the details
For the image I'm using items('For_each'), but i get only image, when i submit the form.
Let me know if any one has idea to display multiple images in the email.
<img src=@{items('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')} />
Adding to what @Skin said, I have embedded each item inside <img>
tag and appended it to a string variable which is then added in the mail body. Below is how my flow looks like.
As a sample I have taken same image 4 times and below are the results in my mail.
Below is the complete codeview of my logic app
{
"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"
}
}
}
}
}
}