Logic Apps, how to send csv query results through email

MarcVanderhaegen 241 Reputation points
2020-11-05T11:45:42.317+00:00

Hello,
I am trying to create a logic app to send results from a log analytics query in csv format through email.

I am able to send the results as an html table with 'run query and visualize results' + 'send an email', that is working perfectly.
But when I try 'run query and list results' + 'create csv table' + 'send email', I can't find a way get the output of the create csv and put it in the attachment of the mail. In the email step I can see for the create csv table 'we can't find any outputs to match this input format'
What am I missing ?
Sorry I am just a beginner in Logic Apps.

The 'create csv table' step is configured with the dynamic content 'value' for the from the from field and the field Columns is configured as Automatic.

Thanks in advance for your help
Marc

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

Accepted answer
  1. MarcVanderhaegen 241 Reputation points
    2020-11-09T18:31:07.823+00:00

    Hello,

    It is solved, there is a see more button that you sometimes need to click to see all the outputs.
    After clicking on it I was able to see the data.

    Marc


1 additional answer

Sort by: Most helpful
  1. Chris H 1 Reputation point
    2021-10-20T04:42:08.377+00:00

    The actions should look like something like this:

    {  
        "definition": {  
            "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",  
            "actions": {  
                "Create_CSV_table": {  
                    "inputs": {  
                        "format": "CSV",  
                        "from": "@body('Parse_JSON')"  
                    },  
                    "runAfter": {  
                        "Parse_JSON": [  
                            "Succeeded"  
                        ]  
                    },  
                    "type": "Table"  
                },  
                "Send_an_email_(V2)": {  
                    "inputs": {  
                        "body": {  
                            "Attachments": [  
                                {  
                                    "ContentBytes": "@{base64(body('Create_CSV_table'))}",  
                                    "Name": "attachment.csv"  
                                }  
                            ],  
                            "Body": "<p></p>",  
                            "Subject": "Email with attached CSV",  
                            "To": "someone@somewhere.com"  
                        },  
                        "host": {  
                            "connection": {  
                                "name": "@parameters('$connections')['office365']['connectionId']"  
                            }  
                        },  
                        "method": "post",  
                        "path": "/v2/Mail"  
                    },  
                    "runAfter": {  
                        "Create_CSV_table": [  
                            "Succeeded"  
                        ]  
                    },  
                    "type": "ApiConnection"  
                }  
    

    If you want to do it via the designer, in the 'Send an email' step, click the 'Add new parameter' dropdown and select 'Attachments'. Wait, and the following will appear. Add an attachment name (it's required, and a run will fail if you don't add one). Click on the 'Attachment content' input field and click the 'See more' link next to 'Create CSV table' to show the 'Output' from Create CSV Table. Drag this into the 'Attachment content' input field.

    141971-image.png