+44(0)1908738254
YOUR EXPERT RPA PARTNER

Team up with our RPA strategy and tech specialists for maximum automation impact

Find out more
Harness the power of UiPath in your business.
WATCH NOW

Save money and spend more time on priority work.

Book consultation
READY, SET, AUTOMATE

Let's choose, design and deploy a process automation solution for your business.

Find out more
TRANSFORM YOUR BUSINESS

Let's analyse your business to discover opportunities for innovation and automation.

Find out more

Begin your business transformation journey

Book consultation
AUTOMATE EVERY FUNCTION

Automate where it matters most. Scale to solve challenges in every area

Find out more
GIVE EVERY TEAM THE TOOLS FOR SUCCESS

Equip people with user-friendly solutions that save time and make work easier

Find out more

Which business problem
can we solve first?

Book consultation
14 September 2017

How to Remove Duplicate Email Addresses in a K2 Email Event

If you use a K2 SmartObject lookup for assigning email addresses dynamically in a K2 Email Event and the source returns duplicate addresses, these are displayed in the in the To/Cc fields of the email. In this blog I will show you how to remove these duplicates. 

Free K2 Five Upgrade Review

STEP 1: Open the workflow .kprx file in Visual Studio

Please note, this technique will only work for K2 processes built in K2 for Visual Studio. 

The K2 process needs to be opened in Visual Studio in order to make changes to the code behind.

STEP 2: Edit the code

Right click on the MailEvent, hover over View Code and select Event Item.

STEP 3: Open the class file

Press F7 or right click and click View Code in the window below.  A new tab will open the Mailevent.Xoml.cs file.

STEP 4: Add a new system reference

Add the refrence: using System.Linq;

STEP 5: Add the following code

Go to the method below and add the code as shown below in the yellow sections highlighted

Notice the Linq “Distinct()” extension method is used to remove duplicates

STEP 6: Save and deploy your K2 process

Save the .cs file and deploy the workflow process. You can now test the email by starting a new instance of the K2 process.

Notice you will receive an email with disticnt recipients.

This simple method will help avoid duplicate recipients in an outgoing email sent by a K2 Email Event.

Need further technical advice or support?