How to find the email address in a particular row and column of a datatable

Hi All,

I want to find out the email address in a particular row and column of a datatable. There are be many columns which may contain email addresses. How to check for the email address in a particular row and column. Can you please help me on it?


Please find the screen shot.

1 Like

Loop through the datatable using For Each row and then check for each column if it matches the email format using RegEx. Example:
IF Regex.IsMatch(row(intColNum),".[@].[.com]") = TRUE THEN Log: Email Found or whatever you want to do

how to get intcolNum? should i initialize that variable? If yes, what should be the value?

intColumn should be the column index of your datatable. To make it easy you can accumulate intColumn in each iteration. Example, your datatable has 7 columns then inside your for each row, you should also have a while loop:
While intColumn < 6
IF Regex.IsMatch(row(intColNum),". [@]. [.com]") = TRUE THEN Log: Email Found or whatever you want to do
intColumn = intColumn + 1

i dont know how many columns contains email address in the data table , it will be dynamically coming? Please suggest what can i do?

If the column is dynamic then you can use, YourDataTableVariable.Columns.Count to get the number of columns

But i dont know which column in the data table consists of email address? Then in this case how i can move further please suggest.

That I have already answered in my first reply…

For Each row in your datatable:
Do while intColNum < (YourDataTable.Columns.Count - 1)
IF Regex.IsMatch(row(intColNum),". [@]. [.com]") = TRUE Then
Do whatever you like with the column that matched the email format
intColNum = intColNum + 1

Hi @ppratz,

Here is an activity called "Find " . It will return the cell info and the row index. It may help you.

Thank you
Balamurugan.S

It says Regex is not declared. And converison from string to double is not allowed

This will help you about that: