System.IndexOutOfRangeException: Index was outside the bounds of the array

Hi,
I am trying to read the Email Subject which is separated by comma[’,’].
I want to split the subject by ‘,’ and store the data in an Array.

But I am facing “Index was outside the bounds of the array.” error near value2 i.e, Assign: Value2 = ArrSub(1) and Robot is terminated.

Any Suggestions on this would be appriciated:)

Ex Subject: ABC,111,XYZ
Assign: ArrSub = EmailSub.Split(NewString(){,} , StringSplitOptions.None)

Assign: Value1 = ArrSub(0)
Assign: Value2 = ArrSub(1)
Assign: Value3 = ArrSub(2)

@changa
Welcome to the forum

Your code lines are looking fine on the first look. In such scenario a debugging and focusing on the content of ArrSub should give a first hint. If ArrSub is empty we do find the reason for the exception. Then we have to check why the Split is failing and will do the root cause analysis

1 Like

Hi @ppr

Thnq for the suggestion, like u said i tried to get the value that is being passed for ArrSub by adding a Message Activity.
But on debugging i could see the value as “FWD:” (but no mail with that particular keyword is present on the top of my gmail inbox) and the my robot got terminated like as before(Assign: Value2 = ArrSub(1)).

Hi @ppr,

My Actual automation workflow was about,
To read the gmail subject that is separated by ‘,’ . And to store the contents of email subject in a DB( I have used MsAccessDataBase).

Please find my .xaml file for my workflow.Main.xaml (11.6 KB)

PF! below SS for table and columns created in DB.

Kindly notice that i have removed the Gmail Id and Pswd in the attached .xaml file.

Any suggestions or modifications would be appreciated :slight_smile: