Retrieve specific word from subject line in Outlook

The Subject line are always. And i need to retrieve the word “STOCKHOLM” and save that word to Excel. The word “STOCKHOLM” can change but the position in subject line doesnt change.

Subject line:
Bbbbbbbbbb för AAAAA BBBBB (1111111) har anvisats till STOCKHOLM (0180)


mybe following regex will help

looking for anything between har anvisats till AND ( ← starting bracket

@Majlopajlo - You can try this, which captures the word without any spaces…

Thank you.
Do i have to use RegEx to solve this. because i have no idea how to apply it. :frowning:

You can try this:

System.Text.RegularExpressions.Regex.Match(StrSubject, "(?<=till).*(?=\()").ToString.Trim

Past this code to activity Assigne.

have a look here:

in case of you are working with API regex.Match… then ensure:

1 Like

@Jan_Exner Is StrSubject the name of the variable?

Yeah! :slight_smile:

If you have a MailMessage type variable, you can try this: “MailMessage.Subject”

@Jan_Exner Here you have my .xaml. I want to identify mails from a certain mailadress. Then i want to extract certain words from the Subject line. And transfer that word to an excel sheet.

And i dont know how to apply RegEx to this

here you have my xaml.
Kommuninformation.xaml (6.0 KB)

Just use an assign activity. The variable strCity will contain the word after “har anvisats till”. It will be empty if there’s no match.

strCity = System.Text.RegularExpressions.Regex.Match(message.Subject, "(?<=har anvisats till\s+)\w+").ToString()

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