Power Apps - 使用Flow将电子邮件发送到收集的用户列表

问题描述 投票:1回答:1

我有一个名为requiredCol_1的集合,像这样,

Name      ID      ToAddress                                                        Status
Abc       123     [email protected],[email protected],[email protected]        A        
Def       234     [email protected],[email protected]                                A
Ghi       567     [email protected],[email protected]                              A

我希望向每个用户发送电子邮件,每个用户只应收到一封电子邮件。

要做到这一点,

我创建了一个requiredCol_2作为另一个集合

ToAddressUnique
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]

我现在设法缩小了我的问题范围。上述集合中的每个用户(requiredCol_2)都会收到一封电子邮件。我的电子邮件正文将连接名称和ID,并以与该特定电子邮件ID相关的列表形式连接。

例如,发送到[email protected]的电子邮件看起来像,

致: - [email protected]

主题: - 请看

身体:-

点击这里,请查看以下内容,

  1. Abc - 123
  2. Def - 234
  3. 记住 - 567

点击这里是一个超链接,我想通过一个变量。

我是Powerapps和流动的新手。所以,请向我解释一下让它工作的步骤。

这是我目前在Power Apps中的代码 - 发送电子邮件按钮

//Create a Collection
ClearCollect(requiredCol_1 , Filter(Table1, User().Email in Lower(Allocators), Status = "A"));

//Unique List of Approvers
ClearCollect(requiredCol_2,Distinct(
    Split(
        Concat(requiredCol_1 , ToAddress, ","),
        ","),
    Result));
//Hyperlink Creation
set (hyperlinkvalue, "WWW.Google.Com");
flow powerapps powerapps-formula powerapps-collection
1个回答
1
投票

如果要发送电子邮件,可以使用其中一个连接器,如Outlook.com或Office 365(以及其他连接器)。如果您希望电子邮件具有超链接,那么您将需要发送HTML电子邮件,并且您需要在应用程序中撰写HTML。例如,下面的代码段显示使用Outlook.com连接器发送电子邮件(Office 365的语法将相同或非常相似):

//Create a Collection
ClearCollect(
    requiredCol_1,
    Filter(Table1, User().Email in Lower(Allocators), Status = "A"));

//Unique List of Approvers
ClearCollect(requiredCol_2,Distinct(
    Split(
        Concat(requiredCol_1 , ToAddress, ","),
        ","),
    Result));

//Hyperlink Creation
Set(hyperlinkvalue, "WWW.Google.Com");

// E-mail body
Set(
    mailBody,
    Concatenate(
        "<p><a href=""",
        hyperlinkvalue,
        """>Click here</a> and kindly review the following:</p>",
        "<ol>",
        Concat(
            requiredCol_1,
            "<li>" & Name & " - " & ID & "</li>"
        ),
        "</ol>"
        ));

// Send e-mail
'Outlook.com'.SendEmail(
    Concat(requiredCol_2, Result, ","),
    "Please look at",
    mailBody,
    {
        IsHtml: true
    })

如果您愿意,只在电子邮件中发送包含该电子邮件的项目,那么您在创建每个电子邮件时需要过滤原始表格,如下例所示:

Set(hyperlinkValue, "www.google.com");
ClearCollect(
    distinctUsers,
    Distinct(Split(Concat(requiredCol_1, ToAddress, ","), ","), Result));
ClearCollect(
    distinctUsersWithEmail,
    AddColumns(
        distinctUsers,
        "mailBodyForUser",
        Concatenate(
            "<p><a href=""",
            hyperlinkValue,
            """>Click here</a> and kindly review the following:</p>",
            "<ol>",
            Concat(
                Filter(requiredCol_1, Result in ToAddress),
                "<li>" & Name & " - " & ID & "</li>"
            ),
            "</ol>"
        )));
ForAll(
    distinctUsersWithEmail,
    'Outlook.com'.SendEmail(
        Result,
        "Please look at",
        mailBodyForUser,
        {
            IsHtml: true
        }))
© www.soinside.com 2019 - 2024. All rights reserved.