Outlook Email Trail

Good day Everybody,

I need some assistance with extracting the first email body from the trail e,g..

This one above would be the first one that came in a trail.


How do I extract only the first message from the trail?

@Anelisa_Bolosha1,

Use this regex to get everything before “From:” which is where second email starts.

^(.*?)(?=From:)

1 Like

In Get email you can filter by something like Subject, From, CC or Subject or Body contains, so that you will get array of all mail messages from this trail.
Then sort it by received time and get first message.

Hi @ashokkarale ,
Thank you for the reply, The email I want is the one from the very bottom of the trail, using your example:

I would want this one in the bottom:

@Anelisa_Bolosha1,

Can you try simple string split


mailbodystring.Split("From:")(mailbodystring.Split("From:").Length-1)

1 Like

Hello, thank you for the response, The emails I get are dynamic it’s not always the same senders

@Anelisa_Bolosha1

After getting your email body in as single string, lets say you are emailbody stored in strEmailBody variable.

in assign activity you can below expression to get the last email

strEmailBody.Substring(strEmailBody.LastIndexOf(“From”))

This give you exact email what you are looking for like below image

Happy Automation!!
If you find the solution, mark it as solution!!

1 Like

it worked thanks so much

1 Like

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