How to give the dynamic condition in contains function to check the email subject line

Hi Guys,

My email subject is

“RE:Fast Ethernet (100 Mb) request to [ UFINET COSTA RICA ] in Tibas, COSTA RICA request [# 788518 ] line item [# 50471231 ]”

i need to check

  • Subject line contains:
    • “request to [“
    • “request [#xxxxxx ]”
    • “line item [#xxxxxxxx ]”

here request number and line items are dynamic so how to check the pattern in condition.

1 Like

Yes of course that’s possible

—use get outlook mail activity and get the list of mail messages with a variable as output named out_mailmessage
— then Use assign activity like this
Out_mailbody= out_mailmessage.Split(Environment.Newline.ToArray())
Where Out_mailboday is a variable of type string array
— now use a for each loop and pass the above variable Out_mailbody as input and change the type argument as string
— inside this use a if condition like
item.Contains(“request to [#“)
If this condition passes it will go to THEN part where we can use the Split method or regex method to get the value of the request using a assign activity

Hope this would help you
Kindly try this and let know for any queries or clarification
Cheers @thima

After getting outlook messages,
take the subject into a string variable and apply regex expressions if the subject matches the given conditions.

For the first condition you can simply use if yourSubject.Contains(“request to [”)
and for other two use regex expressions.

For Example: Regex.Match(strSubject, "request [#\d{6}\s]") will look if subject contains request [#xxxxxx ]

Similarly you have to use Regex expression for other line item also.

Karthik Byggari

1 Like

Hi karthik,

I’m getting errors while checking the conditions like Regex values cannot be converted into Boolean

If you want to check with boolean equivalent, use isMatch

More details here -

Karthik Byggari

Hi karthik,

I tried like this,
System.Text.RegularExpressions.Regex.IsMatch(mail.Subject,“request [#\d{6}\s]”)

i m getting false condition

Hi @thima,

I am pretty sure you’ve probably found a workaround already, but for the sake of sharing knowledge, please find attached a solution which uses only a single activity Get Outlook Mail Messages to filter the e-mail based on your subject requirements.

Subject: RE:Fast Ethernet (100 Mb) request to [ UFINET COSTA RICA ] in Tibas, COSTA RICA request [#788518 ] line item [# 50471231 ]

The solution shows how to use DASL syntax in the Filter property of the activity to achieve such goal.
The dynamic values are stored in variables, check the variables panel.

GetOutlookMailMessages.xaml (4.9 KB)

Please give your hearts if this is helpful! :smiley: