How shall i add validations and make it solid BOT

Hi all,

I am having a .xaml file which has 2 Parts in it…


I written the code for reading the unread emails
i.e i have to read every time all the new email from the Outlook.
So i have set the property(“Top”) of “Get outlook mail messages” “Top” property to =60 i.e Top=60. – is this the right thing to do??? Please let me know if any other ways are there…(i.e every time i have to read all the un read emails)

I just need to do the validations - i.e if emails exists or no … How shall i do this…? i have added the "Try catch " block …
also i am saving them to a Local folder - Suppose if no new emails then how to handle the errors ???

My main consern is handle to errors that is the BOT should not be crashed… How shall i ensure this??

Do i need to add the folder exists - activity??
There is one last thing - how to unzipp the files and save it to the other folder - this one i am not sure , kind of stuck…

**Emails.xaml (22.1 KB)

Can any one please help me with this.


@Seem i have done this before.
I hope u are using the REFramework. I suggest you do as it is the best way. If not you can see the below logic and try and put it in your process

I have done it like this,

  1. Start activity
  2. State 1 - Read emails, so you get the EmailList (top is fine)
    … Check if the count in the list is >0 then save all your emails to folder, else nodata to process so i transition to End Process state
    … Now in Init, fetch the list of emails from the folder and pass it to GetTransactionData where you will check the count of transactionNumber < List.count and you keep setting the transactionItem to the first mail from list and pass it to process.xaml where you can do your processing. This will lopp or all the items in the list.

No need to add folder exists in this case.

It says there in the activity, you pass the path with zip name in the first input
and the path to the folder where u want to extract the data.

Hope it helps

1 Like


Thanks for your replay…
I have to complete it today, very urgent…
What is - REFramework??? i am hearing this first time… Please tell me…

State 1 - Read emails,- is this any new activity… No i could not find it in Uipath…
Which Count??? Do i need to add any counter if so how to add it to the reading emails :frowning:

Now in Init- ?
I am not able to understand further…

Please can you point it out in my .xaml… If you can …


1 Like

Sorry to confuse.
Will explain in detail about REF later when you have time :slight_smile:

I have updated your xaml can you run and do some tweaks where required as i cannot test it. It will fit your purpose Emails.xaml (24.2 KB)


I looked in to the .xaml. It solved most of my problems.
I have one question to you.
You can see that i have used the - Invoke Method - this idea was given to me by one of my colleague …
But i could not understand why to add it… i mean its purpose…
And i understood the - Unzip - activity added by you…


1 Like

Invoke method is a handle to run methods sometimes when you are not using activities or they are not available.
This helps you in directly invoking an available class method like in your case System.IO.Compression.ZipFile and method ExtractToDirectory(does your unzip).

Yes its little difficult to get a hang of this as we are used to using activities thats why @balupad14 's custom activity here to make our lives more simple :slight_smile:

Details of Invoke Method:
InvokeMethod Properties :

MethodName: Assign the method name to this property.
TargetObject: When we want to invoke non-static methods, we need first to create an object that contains the method to execute.
TargetType: When we want to invoke static methods, we specify the type that contains the static method to execute.
GenericTypeArguments: When we want to invoke a generic method, we specify generic types in this collection.
Parameters : The parameter collection of the method to be invoked.
Result: The return value of the method execution.

1 Like


Can you please help me , how we are getting the file name in the variable - FileName

Here is the screenshot i have pasted, i have even marked it in BLACK color

And i want to remove the message box… As its a unattended BOT. If i remove then how will i get the file name…

NOTE: i am executing this code… But the variable - “FileName” is ---- not at all taking the file name…
Please help me.

Thanks in Advance

FileName is a variable…

If you want to get your file name - “System.IO.Path.GetFileNameWithoutExtension(item)”
use this code.

In your case , these are stored in the variable “Filename”
If you want , you can remove your message box also.
message box wont affect anywhere in your program, that is used only for pop-up /display purpose.

I have tweaked your xaml
check it out Emails.xaml (23.6 KB)