Regular expressions and an email

Hello Everyone.

I am trying to get the second line of my email stored into a variable using regular expressions. The email looks like this:

image

I just want the second line of it stored in a variable, but not the hyperlink. How can I use a regular expression to do this and then print it out in a message box to see if it is correct. Right now in my message box I am getting a message that says System.Linq.Enumerable+d_97`1[System.Text.RegularExpressions.Match] and I have no idea what it means.

before processing Matches activity use assign activity to remove the new lines.

strMailContent=strMailContent.Replace(System.Environment.NewLine, “#START”)+"#END"

Pattern in Regex:

((?<=#START).*(?=#END))

You might not even need a regular expression if you know what your email lines are going to be.
Like in your example, if you always want to get only the second line in the email, no matter what it says, you can do
yourSecondLine = yourEmailBody.Split(System.Environment.NewLine)(1)

@kaderms It gives me an error when I try to do this. It assigned the body of the email to a variable

email=item.body.Tostring

and now have
secondLine=email.Split(System.Environment.NewLine)(1) but this produces and error

Can you post that error message?
And maybe one sample email content (paste it as text or attach a notepad)

The error message is “Option Strict on disallows implicit conversion from string to char”. Here is a text file containing the email. Just using this for testing purposes.TestEmail.txt (61 Bytes)

@allurai_india

This does not work, it just prints the whole body of the email.

@amb13
Use secondLine=email.Split(System.Environment.NewLine.ToCharArray)(1) instead, the Split function needs a char array not a string.

1 Like

Yup! sorry my bad!
email.Split(System.Environment.NewLine.ToCharArray)(1) would work.

1 Like