Extract the last part of the subject of an email. Word processing



Dear community,

I would like to be able to read the last part of the subject of an email. At the moment, with the following code, I am able to read the fifth word:

mail.Subject.Split(" "c)(5).ToString

However, what I would really need, is to read from the 5th word onward.

Any suggestions?


Kind regards





@Gennaro_Bozza, Before getting into solution,

As its an array, the index starts from 0 (as we know) then if you wanna get the Fifth word it should be (mail.Subject.Split(" "c)(4)).ToString

Solution: Use String.Join(" ",((mail.Subject.Split(" "c)).Skip(4))) to skip the first four words from subject. It can be made dynamically if you store the value in a variable and pass it.

For Example,

In Assign activity
intger strSkipCount = 4 then

pass the variable as follows,
String.Join(" ",((mail.Subject.Split(" "c)).Skip(strSkipCount)))

Dom :slight_smile:


Hi @Tiberiu_Niculescu

thanks for your hints! The way you wrote it does not work, I am trying to figure out if I manage to fix it but I am currently struggling.

First of all “mailSubject” should be mail.subject. But also by doing it, it returns that “splitArray” was not declared.

Any suggestions?




Hi Dom,

many thanks! Unfortunately it says that this expression cannot be converted into string. But if I use .toString, it returns a meaningless code which is “System.Linq.Enuberable” in place of my desired extract.

Any suggestions?




EDITED: Print this in message box and check,

String.Join(" ",(mail.Subject.Split(" "c)).Skip(4))

Dom :slight_smile:


It works very well @Dominic, thanks a lot!


Hi @Dominic

How can I do the opposite? I.e. extract the text before the 5th word?


@gennaro_bozza, Instead of skip(4) method use take(4).

Dom :slight_smile:


Thanks a lot