1

I have a collection called as requiredCol_1 like this,

Name      ID      ToAddress                                                        Status
Abc       123     asdfg@example.com,koldef@example.com,asdasdasfda@example.com        A        
Def       234     nanasd@example.com,asdfg@example.com                                A
Ghi       567     asdfg@example.com,asdasfg1@example.com                              A

I am looking to send email to each user and each User should receive only one email.

To do that,

I have created a requiredCol_2 as another collection

ToAddressUnique
asdfg@example.com
koldef@example.com
asdasdasfda@example.com
nanasd@example.com
asdasfg1@example.com

I have managed to narrow down my problem now. Every User in the above collection (requiredCol_2) will receive an email. And my email body will have the Name and ID concatenated and in the form of list relevant to that particular email id.

For Example an email sent to asdfg@example.com will look like,

To :- asdfg@example.com

Subject :- Please Look at

Body:-

Click here and Kindly review the following,

  1. Abc - 123
  2. Def - 234
  3. Ghi - 567

Click here is a hyperlink, which I want to pass through a variable.

I am new to Powerapps and flow. So, please explain me the steps to get this to work.

This is my code so far in Power Apps - Send Email Button

//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");
General Grievance
  • 4,555
  • 31
  • 31
  • 45

1 Answers1

1

If you want to send an e-mail, you can use one of the connectors such as Outlook.com or Office 365 (among others). And if you want the e-mail to have hyperlinks, then you will need to send a HTML e-mail, and you'll need to compose the HTML in your app. For example, the code snippet below shows using the Outlook.com connector to send the e-mail (the syntax for Office 365 will be either the same or really similar):

//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
    })

If you want, to send in the e-mail only the items which had that e-mail, then you'll need to filter the original table when creating each individual e-mail, like in the example below:

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
        }))
carlosfigueira
  • 85,035
  • 14
  • 131
  • 171
  • But I think there is one problem..The only problem with this code is, for nanasd@example.com - it will send the email with email body of all 3 Name - ID. Where as, it should send only with the second one...Please guide me there.. – Student of the Digital World Apr 24 '19 at 21:20
  • In your original example you only had one e-mail with all entries. Updated the answer with a way to do what you need. – carlosfigueira Apr 24 '19 at 21:34
  • There is only one problem with that when I use office365 connector. It is not showing the hyperlinks as expected. Please help me with that. https://stackoverflow.com/questions/55847799/power-apps-email-body-not-showing-the-hyperlinks-as-expected – Student of the Digital World Apr 25 '19 at 11:16