Using Array in Logic App: Sending Email with Multiple Recepients

Yasmin, Fitri 231 Reputation points
2021-02-15T17:17:01.31+00:00

I have a storage table with following columns: - SubscriptionOwnerEmail - SubscriptionName - ScheduledUpdate With logic app, I want send an email for all subscription owners when it's time for a scheduled update. That means, the email will contain several email addresses separated by semicolons. I'm thinking of using array variables but I'm not sure how to get the list of email addresses and set them in the variables. ![68423-image.png][1] [1]: /api/attachments/68423-image.png?platform=QnA I'm new to the logic app and wish to get some help for this.

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
2,551 questions
{count} votes

Accepted answer
  1. MayankBargali-MSFT 63,591 Reputation points
    2021-02-22T08:41:16.943+00:00

    Hi anonymous user

    Apology for the delay.
    Get Entities returns the list of object. You need to use Parson JSON method with the input as the response of Get Entities method.
    I have initialized the emaildID's variable of type array. The first loop I am using to loop in with the response of JSON array. The next for loop I have used to split the email ID's. The "append to array variable" will be appending the individual email ID.

    You can modify this according to your needs or business conditions.

    70591-image.png

    For your reference you can refer to below defination file:

    {  
        "definition": {  
            "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",  
            "actions": {  
                "Get_Entities_Items_Loop": {  
                    "actions": {  
                        "Splitting_EmailID_Loop": {  
                            "actions": {  
                                "Append_to_array_variable": {  
                                    "inputs": {  
                                        "name": "emailIDs",  
                                        "value": "@items('Splitting_EmailID_Loop')"  
                                    },  
                                    "runAfter": {},  
                                    "type": "AppendToArrayVariable"  
                                }  
                            },  
                            "foreach": "@split(items('Get_Entities_Items_Loop')['SubscriptionOwnerEmail'],';')",  
                            "runAfter": {},  
                            "type": "Foreach"  
                        }  
                    },  
                    "foreach": "@body('Parse_JSON')",  
                    "runAfter": {  
                        "Initialize_variable": [  
                            "Succeeded"  
                        ]  
                    },  
                    "runtimeConfiguration": {  
                        "concurrency": {  
                            "repetitions": 1  
                        }  
                    },  
                    "type": "Foreach"  
                },  
                "Get_entities": {  
                    "inputs": {  
                        "host": {  
                            "connection": {  
                                "name": "@parameters('$connections')['azuretables']['connectionId']"  
                            }  
                        },  
                        "method": "get",  
                        "path": "/Tables/@{encodeURIComponent('mak')}/entities"  
                    },  
                    "runAfter": {},  
                    "type": "ApiConnection"  
                },  
                "Initialize_variable": {  
                    "inputs": {  
                        "variables": [  
                            {  
                                "name": "emailIDs",  
                                "type": "array"  
                            }  
                        ]  
                    },  
                    "runAfter": {  
                        "Parse_JSON": [  
                            "Succeeded"  
                        ]  
                    },  
                    "type": "InitializeVariable"  
                },  
                "Parse_JSON": {  
                    "inputs": {  
                        "content": "@body('Get_entities')?['value']",  
                        "schema": {  
                            "items": {  
                                "properties": {  
                                    "PartitionKey": {  
                                        "type": "string"  
                                    },  
                                    "RowKey": {  
                                        "type": "string"  
                                    },  
                                    "ScheduledUpdate": {  
                                        "type": "string"  
                                    },  
                                    "SubscriptionName": {  
                                        "type": "string"  
                                    },  
                                    "SubscriptionOwnerEmail": {  
                                        "type": "string"  
                                    },  
                                    "Timestamp": {  
                                        "type": "string"  
                                    },  
                                    "odata.etag": {  
                                        "type": "string"  
                                    }  
                                },  
                                "required": [  
                                    "odata.etag",  
                                    "PartitionKey",  
                                    "RowKey",  
                                    "Timestamp"  
                                ],  
                                "type": "object"  
                            },  
                            "type": "array"  
                        }  
                    },  
                    "runAfter": {  
                        "Get_entities": [  
                            "Succeeded"  
                        ]  
                    },  
                    "type": "ParseJson"  
                }  
            },  
            "contentVersion": "1.0.0.0",  
            "outputs": {},  
            "parameters": {  
                "$connections": {  
                    "defaultValue": {},  
                    "type": "Object"  
                }  
            },  
            "triggers": {  
                "manual": {  
                    "inputs": {},  
                    "kind": "Http",  
                    "type": "Request"  
                }  
            }  
        },  
        "parameters": {  
            "$connections": {  
                "value": {  
                    "azuretables": {  
                        "connectionId": "/subscriptions/{sub}/resourceGroups/backup/providers/Microsoft.Web/connections/azuretables",  
                        "connectionName": "azuretables",  
                        "id": "/subscriptions/{sub}/providers/Microsoft.Web/locations/switzerlandnorth/managedApis/azuretables"  
                    }  
                }  
            }  
        }  
    }  
    

0 additional answers

Sort by: Most helpful