How to see if the mail receiver exists

activities
studio

#1

Hello!! I have this situation:
I want to send an email to the account ABCD@outlook.com, 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!


#2

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);
}


#3

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


#4

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.

Code_Editor


#5

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 - https://msdn.microsoft.com/en-us/library/system.directoryservices(v=vs.110).aspx

Nuget Package link - https://www.nuget.org/packages/System.DirectoryServices/

UIpath how to get custom DLL imported - https://www.uipath.com/kb-articles/how-to-execute-your-custom-code-in-a-workflow

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 ,


#6

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

packages


#7

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


#8

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 https://www.nuget.org/packages/System.DirectoryServices/

Second, I followed the steps in this tutorial https://www.uipath.com/kb-articles/how-to-execute-your-custom-code-in-a-workflow

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

Manage_Packages