cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
lindaisy
Frequent Visitor

Send an email TWICE

Hi, 

I want to send an email with a condtion. The problem is I got 2 emails with the same content every time. 

There is only 1 record in my  collectionA. 

I tried without (ForAll) and it works every well..

 

PS: is that possile change a field in collcionA, saying that the email has been sent (eg: email_sent = true) ? 

 

Thanks for your help ! 

 

ForAll(
    collectionA,
    If(
         condition_new = true ,
        Office365Outlook.SendEmail(
          "email" ,
            "MESSAGE",
            "<b><font color=blue>Confirmed</font></b>",
            {IsHtml: true}
        )
    )
);

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
ZabiBabar
Continued Contributor
Continued Contributor

Confirm that you have only one row in the collection using CountRows(CollectionA) on a Label, and try using SendEmailV2 instead of SendEmail. 

View solution in original post

v-yutliu-msft
Community Support
Community Support

Hi @lindaisy ,

I've made a similar test but not met the same problem like your description.

Here's my test for your reference:

collectionA:

ClearCollect(collectionA,{condition_new:true,Confirmed:"aaa"})

 send email:

ForAll(
    collectionA,
    If(
         condition_new = true ,
        Office365Outlook.SendEmail(
          User().Email ,
            "MESSAGE",
            "<b><font color=blue>Confirmed</font></b>",
            {IsHtml: true}
        )
    )
);

Then I only get one emial.

 

Please check whether you only have one rows that meet this requirement: "condition_new = true ".

Since you use forall function, the number that you send email will be decided by the record number that meet this requirement: "condition_new = true ".

 

What's more, if you want to mark record ,saying that the email has been sent, please insert a column in your collection.

I assume that field named  email_sent.

Try this formula:

ForAll(
    RenameColumns(collectionA,"ID","ID1"),
    If(
         condition_new = true ,
        Office365Outlook.SendEmail(
          User().Email ,
            "MESSAGE",
            "<b><font color=blue>Confirmed</font></b>",
            {IsHtml: true}
        );Patch(collectionA,LookUp(collectionA,ID=ID1),{email_sent:true})
    )
);

//ID is the unique field in this collection, you could replace with other unique field.

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
ZabiBabar
Continued Contributor
Continued Contributor

Confirm that you have only one row in the collection using CountRows(CollectionA) on a Label, and try using SendEmailV2 instead of SendEmail. 

v-yutliu-msft
Community Support
Community Support

Hi @lindaisy ,

I've made a similar test but not met the same problem like your description.

Here's my test for your reference:

collectionA:

ClearCollect(collectionA,{condition_new:true,Confirmed:"aaa"})

 send email:

ForAll(
    collectionA,
    If(
         condition_new = true ,
        Office365Outlook.SendEmail(
          User().Email ,
            "MESSAGE",
            "<b><font color=blue>Confirmed</font></b>",
            {IsHtml: true}
        )
    )
);

Then I only get one emial.

 

Please check whether you only have one rows that meet this requirement: "condition_new = true ".

Since you use forall function, the number that you send email will be decided by the record number that meet this requirement: "condition_new = true ".

 

What's more, if you want to mark record ,saying that the email has been sent, please insert a column in your collection.

I assume that field named  email_sent.

Try this formula:

ForAll(
    RenameColumns(collectionA,"ID","ID1"),
    If(
         condition_new = true ,
        Office365Outlook.SendEmail(
          User().Email ,
            "MESSAGE",
            "<b><font color=blue>Confirmed</font></b>",
            {IsHtml: true}
        );Patch(collectionA,LookUp(collectionA,ID=ID1),{email_sent:true})
    )
);

//ID is the unique field in this collection, you could replace with other unique field.

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

hi @ZabiBabar ,

Thanks for your help! 

I modified and it works very well now !!! 

 

 

 Hi @v-yutliu-msft , 

Thanks a lot for your help ! 

I also tried your solution, works great ! 

😀

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events that are happening this month - don't miss out!

Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (2,701)