如何使用PowerAutomate和ADF将SQL查询结果作为邮件发送

huangapple go评论103阅读模式
英文:

How to send a SQL query output as a mail using PowerAutomate and ADF

问题

I have a task in which I want to send a SQL QUERY OUTPUT as mail body using Power Automate and ADF.
I am creating a Lookup activity in ADF where I am passing my query as:
select * from adventure table
where Animals = 'Lion' and Jungle = 'Amazon'.
this table is available in the SQL Database.

the output of the above query I want to send in the mail body not as a CSV attachment but as the mail body only in the form of a table so the third party can directly view the data in the mail only using Power Automate Flow. This flow should run every 1 hour daily.

Mail subject should look like:
FROM: People@gmail.com
TO: Linking@gmail.com
Subject: Animals Details
Hi XXXXX,
these are the animal details:

output of SQL query:
in table format

Thanks
Retailer

英文:

I have a task in which i want to send a SQL QUERY OUTPUT as mail body using Power Automate and ADF.
i am creating a Lookup activity in ADF where i am passing my query as:
select * from adventure table
where Animals = 'Lion' and Jungle = 'Amazon'.
this table is available in the SQL Database.

the output of the above query i want to send in mail body not as csv attachment but as mail body only in form of table so third party can directly view the data in mail only using Power Automate Flow. this flow should run in every 1 hour daily.

 mail SUbject should look like:
    FROM: People@gmail.com
    TO : Linking@gmail.cok
    Subject: Animals Details
    Hi XXXXX,
    these are the animal details :

output of SQL query: 
in table format

Thanks
Retailer

答案1

得分: 1

以下是您可以尝试以满足您需求的方式。在查找活动后,我在Power Automate中使用了Web活动,并进行了如下的POST调用。

如何使用PowerAutomate和ADF将SQL查询结果作为邮件发送

Body - @activity('Lookup1').output.value

在Power Automate中,流程可以结构化如下。

如何使用PowerAutomate和ADF将SQL查询结果作为邮件发送

这是为示例数据生成的模式:

{
    "items": {
        "properties": {
            "animal": {
                "type": "string"
            },
            "id": {
                "type": "integer"
            }
        },
        "required": [
            "id",
            "animal"
        ],
        "type": "object"
    },
    "type": "array"
}

示例数据:

[
  {
    "id": 1,
    "animal": "Dog"
  },
  {
    "id": 2,
    "animal": "Cat"
  },
  {
    "id": 3,
    "animal": "Raccoon"
  }
]

结果:

如何使用PowerAutomate和ADF将SQL查询结果作为邮件发送

英文:

Below is something you can try to achieve your requirement. After the lookup activity, I used Web Activity and did a post call on power automate as below.

如何使用PowerAutomate和ADF将SQL查询结果作为邮件发送

Body - @activity('Lookup1').output.value

Flow in power automate can be structured as below.

如何使用PowerAutomate和ADF将SQL查询结果作为邮件发送

Here is the schema generated for the sample data

{
    "items": {
        "properties": {
            "animal": {
                "type": "string"
            },
            "id": {
                "type": "integer"
            }
        },
        "required": [
            "id",
            "animal"
        ],
        "type": "object"
    },
    "type": "array"
}

sample data

[
  {
    "id": 1,
    "animal": "Dog"
  },
  {
    "id": 2,
    "animal": "Cat"
  },
  {
    "id": 3,
    "animal": "Raccoon"
  }
]

Results:

如何使用PowerAutomate和ADF将SQL查询结果作为邮件发送

huangapple
  • 本文由 发表于 2023年5月18日 02:00:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/76274977.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定