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?
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
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
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