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

email
studio
variable

#1

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?

Thanks

Kind regards

Gennaro


#2

mailSubject.substring(mailSubject.indexOf(splitArray(4)))


#3

@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)))

Regards,
Dom :slight_smile:


#4

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?

Thanks

Gennaro


#5

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?

Thanks

Gennaro


#6

EDITED: Print this in message box and check,

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

Regards,
Dom :slight_smile:


#7

It works very well @Dominic, thanks a lot!


#8

Hi @Dominic

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


#9

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

Regards,
Dom :slight_smile:


#10

Thanks a lot