cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Dhinesh28R
Post Prodigy
Post Prodigy

Avoid duplicate elements in Email To Address

Hi,

In my app i need to send emails to Multiple Users from multiple source.

First i set an one variable. In that variable two mail ids are there.

After that am getting mail addresses from O365 group.

Now i append O365 to existing Initialized variable.

Now am giving that variable into a Send email To address.

 

Initialize variable:

ini var.JPG

 

O365 member to append variable:

o365 grp var.JPG

 

Send Email:

mail var.JPG

 

Now am getting Duplicates mail ids when am getting a mail.

 

 

How to avoid duplicate in a To address?

 

Thanks,

Dhinesh.

 

12 REPLIES 12
Nogueira1306
Super User
Super User

Hey! Check if the 2 emails are the same. If yes, just send to 1, if not, send to both

 

If you need additional help please tag me in your reply and please like my reply.
If my reply provided you with a solution, pleased mark it as a solution ✔️!

Best regards,
Gonçalo Nogueira

Hi @Nogueira1306,
How to check a variable?

 

I append my O365 group members mail to existing variable.

 

Then how i check ? IS it possible?

 

 

Following is my example looks like,

Email
User@demo.com

 

O365 group members mail,

mail
User@demo.com
User1@demo.com

 

Now am getting mail like this in To address,

User@demo.com;User@demo.com;User1@demo.com

 

But what i actually i want is,

User@demo.com;User1@demo.com

 

Thanks,

Dhinesh.

ekarim2020
Super User
Super User

This can be achieved using an array variable, the union and join functions.

ekarim2020_10-1629724962295.png

Start with an array variable. Append each email address using the Append to Array action:

ekarim2020_0-1629723375601.png

This will result in varEmail containing the following email addresses, including duplicates:

ekarim2020_1-1629723476369.png

Then we use the Union function to remove the duplicate email addresses:

ekarim2020_2-1629723520399.png

The expression to use is:

 

union(variables('varEmail'),variables('varEmail'))

 

This will result in the duplicates being remove. The result stored in the Compose Remove Duplicates:

ekarim2020_3-1629723636259.png

Finally, we join all the email addresses together, with each email address separated using the semi-colon character (;) to create an Outlook ready recipient list:

ekarim2020_8-1629724477863.png

The join expression is:

 

join(outputs('Compose_Remove_Duplicates'),'; ')

 

The recipient list looks like this with no duplicates:

ekarim2020_5-1629723776604.png

ekarim2020_6-1629723884095.png

Hope this helps.

Ellis

eric-cheng
Solution Sage
Solution Sage

Hi @Dhinesh28R ,

 

Screenshot_20210823-220636_Chrome.jpg

--------------------------------------------------------------------------
If I have answered your question, please mark my post as a solution
If you have found my response helpful, please give it a thumbs up

Connect on LinkedIn

Hi @ekarim2020,
My variable is String type its not an array. 

Its cant accept by union function. It's getting following error ,
Unable to process template language expressions in action 'Compose' inputs at line '1' and column '3351': 'The template language function 'union' expects either a comma separated list of arrays or a comma separated list of objects as its parameters. The function was invoked with parameters of type 'String'.

 

Thanks,
Dhinesh

Hi @eric-cheng,

If it does not contain variable values in a O365 yes condition is ok,

If it is contain am how to avoid duplicate ?

 

Thanks,

Dhinesh

eric-cheng
Solution Sage
Solution Sage

Hi @Dhinesh28R ,

 

Based on the screenshot provided, if it does not contain the email, it will append the email, otherwise skip.

 

I am on mobile hence the designer is set to responsive.

 

--------------------------------------------------------------------------
If I have answered your question, please mark my post as a solution
If you have found my response helpful, please give it a thumbs up

Connect on LinkedIn

Hi @eric-cheng,
I don't need to skip or duplicate email to append.

That's what now am getting issue.

 

Thanks,

Dhinesh

eric-cheng
Solution Sage
Solution Sage

Hi @Dhinesh28R ,

 

Read my last post carefully.

 

--------------------------------------------------------------------------
If I have answered your question, please mark my post as a solution
If you have found my response helpful, please give it a thumbs up

Connect on LinkedIn

ekarim2020
Super User
Super User

The initial variable needs to be of type Array in order for the flow to work.

Initializing the array with a number of email addresses:

ekarim2020_0-1629726803537.png

["James@james.com", "bill@bill.com", "ali@ali.com"]

 

ekarim2020_1-1629726872976.png

But you should only append element of the array at a time. This means that your flow may require some modifications.

Ellis

ekarim2020
Super User
Super User

You can "grab" the email addresses of the member of your 365 group using a loop and append to array action, such as:

ekarim2020_0-1629727604633.png

Ellis

Hi @ekarim2020 , @eric-cheng ,

I converted a string variable to an array by using split function.

After that i did an union function after that with join function. Now its remove duplicates from To Address.

Now its working fine.

 

Thanks,

Dhinesh.

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Users online (4,012)