Power Automate: Read Email from Outlook.com, Write to Excel on OneDrive
Setup
To set up this workflow, follow these steps:
- Sign in to Power Automate and create a new flow.
- Choose "When a new email arrives" as the trigger, and select your Outlook.com account.
- Add the "Excel - Add row" action and connect to your OneDrive Excel file.
- Map the email properties to the appropriate Excel columns.
- Add the "Condition" action to check if the email was received in the previous month (mid-December).
- If the condition is true, add the "Power Automate - Start a new flow" action to run the specified workflow.
- Save and test the flow.
Code Example
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Add_row": {
"inputs": {
"tableName": {
"type": "string",
"defaultValue": "Sheet1"
},
"values": {
"Subject": {
"type": "string",
"value": "@triggerBody()?['Subject']"
},
"From": {
"type": "string",
"value": "@triggerBody()?['From']"
},
"ReceivedTime": {
"type": "string",
"value": "@utcNow()"
}
}
},
"runAfter": {},
"type": "Excel_Add_row"
},
"Condition": {
"inputs": {
"conditions": [
{
"odataType": "Edm.Boolean",
"value": "@equals(utcNow(), addDays(utcNow(), -30))"
}
],
"operator": "And"
},
"runAfter": {},
"type": "Condition"
},
"Start_a_new_flow": {
"inputs": {
"flowId": {
"type": "string"
}
},
"runAfter": {},
"type": "PowerAutomate_Start_a_new_flow"
}
},
"contentVersion": "1.0.0.0",
"parameters": {},
"triggers": {
"manual": {
"type": "manual"
},
"when_a_new_email_arrives": {
"type": "apiConnection",
"inputs": {
"api": {
"runtimeUrl": "https://outlook.office365.com/api/v2.0",
"authentication": {
"type": "anonymous"
}
},
"body": {
"filter": {
"sent": {
"value": "false"
},
"receivedDateTime": {
"value": "@utcNow()",
"type": "datetime"
}
},
"top": 1
},
"method": "GET",
"recurrence": {},
"splitOn": "receivedDateTime",
"triggerBody": {
"contentType": "application/json",
"type": "expression"
}
},
"type": "apiConnection"
}
}
}
}