Not pulling in all data

I am trying to pull in data from the body of an email, then insert it into a SQL table. The piece of information in the body is an email address. When the body only contains 1 email, no issues but when there are multiple, it only pulls the top email. How do i get it to pull all email addresses to insert into my SQL table? Here is how i pull emails and also a sample of what the body looks like.

Sample body:

Expression to pull email from body:

You are using Regex.Match it will store only one value. Try Regex.Matches. It will store all the matches in a collection and you can get all values using for each item loop. You have to change the data type of variable in which you are storing the result to IEnumerable<Match>

1 Like

@atarantino as @kumar.varun2 said, you had to use the Matches instead of Match

Detailed code

emails_list = System.Text.RegularExpressions.Regex.Matches(mail.body,"(?<=Email:).*(?=\.)").Cast(OfMatch).Select(Function(e) e.Value.ToString).ToArray

email_list will be array of type string.

hope it helps you

Nived N
Happy Automation

1 Like

Hi @NIVED_NAMBIAR …thank you for the code. When I put it in i get the below error.

Of Match

Give space between both

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.