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
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (7,022)