Hello All,
I have been asked to see if an automated email can be sent from a mailbox when it detects a certain category. I have at the moment managed to scan the mailbox for a specific category and then parse the email into JSON.
The issue I am having is when trying to send an email in the next step it is failing with the following:
Flow run failed. Action 'For_each' failed: The execution of template action 'For_each' failed: the result of the evaluation of 'foreach' expression '@outputs('Parse_JSON')?['body']?['body']?['value']' is of type 'Null'. The result must be a valid array.
Here is the code for the For Each step:
{
"type": "Foreach",
"foreach": "@outputs('Parse_JSON')?['body']?['body']?['value']",
"actions": {
"Send_an_email_(V2)": {
"type": "OpenApiConnection",
"inputs": {
"parameters": {
"emailMessage/To": "@items('For_each')?['sender']?['emailAddress']?['address']",
"emailMessage/Subject": "Test Response",
"emailMessage/Body": "<p class=\"editor-paragraph\">Test Response</p>",
"emailMessage/Importance": "Normal"
},
"host": {
"apiId": "/providers/Microsoft.PowerApps/apis/shared_office365",
"connection": "shared_office365",
"operationId": "SendEmailV2"
}
}
}
},
"runAfter": {
"Parse_JSON": [
"Succeeded"
]
}
}
I have attached the JSON code.
I am not sure what the For Each loop is looking for.
Any help would be greatly appreciated.
Kind Regards,
Sean Buckle