Get String from email after certain word in the body

Hi,

I need to grab a some text from the body of an email after a certain word.
The emails are using html and I need to grab the string after “Message Id: "
I’ve tried mail.body.split(”:"C).Last.Trim, but I cant use this as there are many “:” in the body and I’ve also tried to use “<” but there are also too many of those as well.

1 Like

Hi @michael.p.wilson
Please try this one:
mail.body.ToString.Substring(trialVar.IndexOf("Message ID: ")+“Message ID:”.Length).Split(Environment.NewLine.ToCharArray)(0)
Thanks and regards,
Despi

1 Like

I havent been storing the mail.body in a string. Can I just put
mail.body.ToString.Substring(mail.body.IndexOf(

2 Likes

mail.body.ToString.Substring(mail.body.ToString.IndexOf("Message ID: ")+“Message ID:”.Length).Split(Environment.NewLine.ToCharArray)(0)
Let me know if this helps, @michael.p.wilson :slight_smile:

5 Likes

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