How to see if the mail receiver exists



Hello!! I have this situation:
I want to send an email to the account, but first I want to check if that account exists. If it exists I want to send the email, if it does not exist I do not want to do anything.

How can I do with UiPath to check if the recipient exists? Thank you!


The best way would be to validate it against AD (Active directory) , if the email address is in your domain itself you can check it against the AD. but if its outside the domain … then it would be difficult …

Try this for searching on AD .

using System.IO;

bool EMailExists(string emailID)

DirectoryEntry objDirEnt = new DirectoryEntry(@“LDAP://yourLDAPAddress”);
DirectorySearcher objSearcher = new DirectorySearcher(objDirEnt);
objSearcher.Filter = “(&(objectClass=user)(email=” + emailID+ “))”;

SearchResult result = objSearcher.FindOne();

return (result != null);


Perfect!! Thank you so much!! :slight_smile:


Hi, I tried to do the same code in VB, but when I put it in a flowchart, it started throwing errors. I have 2 questions: How can I fix it? Is the code correct? I appreciate the help.

These are the errors

This is the code. I just removed the semicolon from the first line.



Hi @Juan_Perez ,

Its because the namespace is not included,
We would need to pull in the DirectoryServices name space into UIpath and then use it via the custom code.

MSDN Link for Directory Services -

Nuget Package link -

UIpath how to get custom DLL imported -

Once you obtain the required dlll , follow the last guide to import the dll as a reference and get a nuget package created for it. And then install the package , and then from Namespaces window , import the namespace.

I know its not straight forward :slight_smile: you can give it a try meanwhile i will also work on getting this nuget created , and will share once i get done ,


Thank you very much Sai.kiran, I’m trying to do that. The problem is that UiPath Studio does not show me the package. I already put the package in the Uipath folder, the Activities folder, and the Packages folder. And the ManagePackages does not show me the package I made :frowning:

I downloaded the DirectoriesServices file and created the file following the NuGet tutorial



Could you try adding this path in the package source ? maybe its not included ?


I think I’m close to achieving it. I put the file in ActivitiesFolder, and instead of the Install option, it appeared directly installed in UiPath. But it does not work.

I did 2 things: first I downloaded the DirectoryServices from here

Second, I followed the steps in this tutorial

I did not modify the DirectoryServices, nor the code I did in VB.