In UiPath RPA Tool Create A Sequence Project For Sending Mail Using SMTP Activity By Taking Credentials From Orchestrator Assets

In this article, we are going to see how to create a RPA Project to send an email by taking credentials from UiPath Orchestrator. Though I have covered the basics this article assumes you already know the basics of UiPath.
 

What is RPA

 
RPA stands for Robotic Process Automation. It is an emerging form of business process automation technology which provides easy GUI based tools and activity to automate business process.
 
Here we are using UiPath RPA Tool.
 
First Install RPA Tool UiPath Community Edition from here.
 
Simple Hello World and Web Scraping projects/program articles are already in C# Corner.
 

What is an Asset?

 
Google says Assets usually represent shared variables or credentials that can be used in different automation projects. They give you the opportunity to store specific information so that the Robots can easily have access to it.
 
In simple words, it is a variable created in orchestrator to save secure information (passwords) or information that can be shared or changed by users who have orchestrator access.
 
First we will see steps for creating an Asset in Orchestrator.
 
Go here.
 
Then go to Services.
 
Then go to your created services; if you haven't created this already,  then first create your service.
 
Then go to assets.
 
Click on + sign to create an asset
 
Select type credential; it will ask username and password,
 

Figure 1: Creating Asset
 
Note
If you are working with RE Framework then the name in Excel Config file under Data is the name you will pass in arguments in Uipath studio.
 
And the value in config file is Asset name.
 
Now we will see the actual implementation for Mail Sending Activity (SMTP Activity).
 
First, create an asset for email and password in Orchestrator.
 
 
Then create an asset for port number
 
Fig3_Creating Asset For Port Number
 
Then create an asset for server
 
Fig4_Creating Asset For Server
 
After creating asset for all your important credentials, go to Uipath Studio.
 
Create Blank Process.
 
Take the "Get Credential" activity from activities from left panel.
 
Take and drop into drop activities.
 
Create two variables.
 
Email as string and password as a secure string.
 
Fig5_Creating Sequence and using Get Credential Activity
 
Give asset name as given in orchestrator.
 
Fig6_Giving Asset name same as given in Orchestrator
 
Provide or assign these variables to respective output properties.
 
Fig7_Assign Variables to respective output properties
 
When you get the password from orchestrator asset, password is of secure string type but your SMTP activity needs password in string type.
 
For that we are creating new variable as StrPassword.
 
And using assign activity pass the secure string type password to StrPassword variable
 
Type this into the value of assign activity: "new System.Net.NetworkCredential(string.Empty, password).Password"
 
Fig8_Assign activity to convert securestring To string
 
Now to get the Port number and Server address we are using "Get Asset" activity as port number and server is only text or string -- we don’t have a password to secure.
 
First, create two new variables of string type "port" and "server"
 
Fig9_Creating two new variables of string type for port and server
 
Provide name of the Asset AssetName field and respective variable in output value field. It will assign the value from orchestrator asset to our variable.
 
Fig10_Using Get Asset Activity
 
Then take the SMTP activity from left panel and drop in your sequence.
 
And fill in all the required fields like port, server, email, password, etc.
 
Fig11_Using SMTP Activity
 
Convert the port number to int.
 
By using Convert.Int32(port) as our port variable it is of string type.
 
After filling all the details it will look like this,
 
Fig12_Final Screen shot of Main
 
Now just run it  -- it will shoot the mail to the given mail id.
 

Conclusion

 
Now the Uipath Project for sending email using SMTP activity by taking credentials from Orchestrator asset is completed and you can use this in any of your projects for sending an email. All Credential variables are stored as asset in orchestrator. This means you can change the email credentials, port, and even server without modifying your UiPath Project.


Similar Articles