Skip to content

Instantly share code, notes, and snippets.

@justinyoo
Created August 13, 2019 13:46
Show Gist options
  • Save justinyoo/b0865f6d2b7c42645e2e8a2058a0de1f to your computer and use it in GitHub Desktop.
Save justinyoo/b0865f6d2b7c42645e2e8a2058a0de1f to your computer and use it in GitHub Desktop.
Enriching Mail Filtering Rules by Azure Logic Apps
"Filter_Recipients": {
"type": "Query",
"runAfter": {
"Get_All_Recipients": [
"Succeeded"
]
},
"inputs": {
"from": "@variables('FolderLookupReferences')",
"where": "@contains(outputs('Get_All_Recipients'), item()?.email)"
}
}
"Get_All_Recipients": {
"type": "Compose",
"runAfter": {
"Initialise_Folder_Lookup_References": [
"Succeeded"
]
},
"inputs": "@union(coalesce(split(triggerBody()?['Cc'], json('[]')), ';'), split(coalesce(triggerBody()?['To'], json('[]')), ';'))"
},
[
{
"email": "mvp-dotnet@mailing-list.net",
"folderId": "AQMkADAwAT****************AAAA==",
"displayName": ".NET"
},
{
"email": "mvp-asp.net@mailing-list.net",
"folderId": "AQMkADAwAT****************AAAA==",
"displayName": "ASP.NET-IIS"
},
{
"email": "mvp-azure@mailing-list.net",
"folderId": "AQMkADAwAT****************AAAA==",
"displayName": "Azure"
},
{
"email": "mvp-devops@mailing-list.net",
"folderId": "AQMkADAwAT****************AAAA==",
"displayName": "DevOps"
},
{
"email": "mvp-integration@mailing-list.net",
"folderId": "AQMkADAwAT****************AAAA==",
"displayName": "Integration"
},
{
"email": "mvp-office365@mailing-list.net",
"folderId": "AQMkADAwAT****************AAAA==",
"displayName": "Office365"
},
{
"email": "mvp-windows@mailing-list.net",
"folderId": "AQMkADAwAT****************AAAA==",
"displayName": "Windows"
},
{
"email": "mvp-xamarin@mailing-list.net",
"folderId": "AQMkADAwAT****************AAAA==",
"displayName": "Xamarin"
}
]
[
{
"id": "AQMkADAwAT****************AAAA==",
"displayName": ".NET"
},
{
"id": "AQMkADAwAT****************AAAA==",
"displayName": "ASP.NET-IIS"
},
{
"id": "AQMkADAwAT****************AAAA==",
"displayName": "Azure"
},
{
"id": "AQMkADAwAT****************AAAA==",
"displayName": "DevOps"
},
{
"id": "AQMkADAwAT****************AAAA==",
"displayName": "Integration"
},
{
"id": "AQMkADAwAT****************AAAA==",
"displayName": "Office365"
},
{
"id": "AQMkADAwAT****************AAAA==",
"displayName": "Windows"
},
{
"id": "AQMkADAwAT****************AAAA==",
"displayName": "Xamarin"
}
]
"Move_Email_to_Designated_Folder": {
"type": "ApiConnection",
"runAfter": {
"Take_the_First_Recipient": [
"Succeeded"
]
},
"inputs": {
"method": "post",
"host": {
"connection": {
"name": "@parameters('$connections')['outlook']['connectionId']"
}
},
"path": "/Mail/Move/@{encodeURIComponent(triggerBody()?['Id'])}",
"queries": {
"folderPath": "Id::@{outputs('Take_the_First_Recipient')?['folderId']}"
}
}
}
"Stop_Processing_If_Filter_Returns_Empty": {
"type": "If",
"runAfter": {
"Filter_Recipients": [
"Succeeded"
]
},
"expression": {
"and": [
{
"equals": [
"@length(coalesce(body('Filter_Recipients'), json('[]')))",
0
]
}
]
},
"actions": {
"Cancel_Processing_Due_to_No_Recipient_Found": {
"type": "Terminate",
"runAfter": {},
"inputs": {
"runStatus": "Cancelled"
}
}
}
}
"Take_the_First_Recipient": {
"type": "Compose",
"runAfter": {
"Stop_Processing_If_Filter_Returns_Empty": [
"Succeeded"
]
},
"inputs": "@first(body('Filter_Recipients'))"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment