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}
)
)
);
Solved! Go to Solution.
Confirm that you have only one row in the collection using CountRows(CollectionA) on a Label, and try using SendEmailV2 instead of SendEmail.
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,
Confirm that you have only one row in the collection using CountRows(CollectionA) on a Label, and try using SendEmailV2 instead of SendEmail.
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,
User | Count |
---|---|
164 | |
96 | |
78 | |
73 | |
59 |
User | Count |
---|---|
205 | |
167 | |
98 | |
94 | |
79 |