Error in the loop

Hi can you plz help to resolve this error

if you see EmailAdd in the assigned activity is stored the text using Match activty.


Hello @balkishan
Email count is integer .this is not right parameters for foreach activity.
You should be pass list of email in this parameters



@sandeep13 Hi thanks for your response.

Here bro, I am using the Match Activity to extract the email address from the bulk text and then I count the number of times existing the @ in the text so that I can count the how many email address a candidate has?

So I count the number of times @ in the text. Then I use the loop to write the email add in the excel file. Hope you understand it. can you plz guide me what to do to next. Thanks

@Jan_Brian_Despi and @sandeep13 can you help plz

1 Like

Hi buddy
Firstly it was mentioned in the question like EmailAdd, but it is mentioned as Emailcount

Second, In for each loop, we can pass variable of type collections, like array, list, dictionary, etc…so kindly make sure that the variable been passed to the loop is of the above mentioned types buddy

Third if you want to iterate with a count value as a condition like emailcount we can use a while loop or a do while loop Activity
So for that add a counter variable of type int32 with default value of 0 and use condition in while loop like this
Counter < Emailcount
Edit @balkishan
Then use a add data row Activity and then next use a assign activity to increment the value of counter
Counter = Counter +1

Thats all buddy
Kindly try this and let know for queries or clarification
Cheers @balkishan

1 Like

Bro, Thanks for your reply. EmailAdd is containing the text and Emailcount is used to count the number of times exiting @ from the text.

No worries
Then we can try while loop or do while loop buddy
Kindly try and let know :slight_smile:
Cheers @balkishan

1 Like

Hello @balkishan
So you can use while loop instead of foreach.
Iterates untill email count will be zero

Teriminate condition should be emalcount>0
In body section emailcount= emaicount-1
Hope it will help

1 Like

Bro I have to write the email with , in the excel sheet in a single row, if there are more than one email address exisiting.

Like - image

So how to write this condition.

Were they are stored in any variable
Cheers @balkishan

1 Like


If you store the values in a string variable with the comma separated syntax then you can directly use that variable in side the add data row activity.

1 Like

@Palaniyappan yes bro image

EmailAdd is containing the email id value after filtered it using the Regex expression and then emailCount the number of times @ from the text. If it count then there is one email for candidate if two times @ then two like that.

No bro it’s not storing the directly value. value come from the candidate profile then filter it using the Regex…

May I know what is the value of EmailAdd variable
Cheers @balkishan

1 Like

Bro is the condition same as @Palaniyappan posted. It seems diff. correct me If I am wrong.

see bro

Are you there bro @Palaniyappan

1 Like

I suspect that your Assign in your original post has .Count on the end to assign to an Integer. Can you show the exact code you have there?

You really don’t want to use a Do While loop for this… So if you can get an Array from your string of all the emails, you can run that through the ForEach. However, you are storing a Count instead.


Please see @ClaytonM

Let me also add by quoting this part.

You can simply split this list by a comma, and run that through the For Each…
Like this:

Assign emailIDs = row("Email I'd").ToString.Split(","c)
For each id In emailIDs

Or if you chose to use Regex to get your list of emailIDs, then run that through the For each.


1 Like

@ClaytonM Attached screenshot is just an example, How I want to write the email I’d into the excel. Real value coming from the Regex exp after filtration.

Gotcha, so where is the part where you get the Email address using Regex? And do you have an example when there are more than one email id?

If you can simply store the emails to an array, then you can join them with a comma.

For example,
Add Data Row using String.Join(", ", emailIDs)

No loop needed