How to get the latest email data from an email thread

Hi all,
I want to get the data of latest reply of an email from an email thread. Like in below thread there are 5 emails reply and i only want to get the email 5 data.

email 5:
App

[EXTMSG] 434343sdf454
whats
POD 1324182333

ABCDCOM srgdgg6446645
there
Manually

Tayyab Imtiaz

From: Muhammad Tayyab Imtiaz
Sent: Friday, November 24, 2023 4:37 PM
To: Muhammad Tayyab Imtiaz
Subject: RE: ONLY_SUBJECT

email 4:
ABCDCOM srgdgg6446645
there
[EXTMSG] 434343sdf454
whats
POD 1324182333
App
Manually
[EXTMSG] 434343sdf454
whats
POD 1324182333

ABCDCOM srgdgg6446645
there
Manually

Tayyab Imtiaz

From: Muhammad Tayyab Imtiaz
Sent: Friday, November 24, 2023 4:36 PM
To: Muhammad Tayyab Imtiaz
Subject: RE: ONLY_SUBJECT

email 3:
POD 13241828
[EXTMSG] ub40226277774
ABCDCOM 753977553445

[EXTMSG] 434343sdf454
whats
POD 1324182333

ABCDCOM srgdgg6446645
there
Manually

Tayyab Imtiaz

From: Muhammad Tayyab Imtiaz
Sent: Friday, November 24, 2023 4:36 PM
To: Muhammad Tayyab Imtiaz
Subject: ONLY_SUBJECT

email 2:
POD 13241818
[EXTMSG] ub4022620534
ABCDCOM 090075601

Tayyab Imtiaz

From: Muhammad Tayyab Imtiaz
Sent: Friday, November 24, 2023 4:36 PM
To: Muhammad Tayyab Imtiaz
Subject: ONLY_SUBJECT

email 1:

POD 13241818
[EXTMSG] ub4022620534
ABCDCOM 090075601

Tayyab Imtiaz

Hello @tayyabimtiaz1

  1. Assign latestEmailContent = “…” ’ Replace with the actual content of the latest email

  2. Assign regexPattern = “(POD \d+|ABCDCOM \w+|Manually|Tayyab Imtiaz)”

  3. Assign matches = System.Text.RegularExpressions.Regex.Matches(latestEmailContent, regexPattern)

  4. For Each match In matches

  5. LogMessage(match.ToString)

Thanks & Cheers!!!

latestEmailContent is the list of mails<< right and then regexPattern variable type should pe str?? from where i have to select my inbox mails etc. some difficulties to understand your thoughts. Can you please more elaborate

@tayyabimtiaz1

  1. Get Outlook Mail Messages:

    • Use the “Get Outlook Mail Messages” activity to get emails and store them in the variable ‘mailsList’.
  2. Find the Latest Email:

    • Use LINQ or other methods to find the latest email from ‘mailsList’.
    • Assign the latest email to a variable ‘latestEmail’.
  3. Extract Email Content:

    • Assign latestEmailContent = latestEmail.Body
  4. Apply Regular Expression:

    • Assign regexPattern = “(POD \d+|ABCDCOM \w+|Manually|Tayyab Imtiaz)”
    • Assign matches = System.Text.RegularExpressions.Regex.Matches(latestEmailContent, regexPattern)
  5. Loop through Matches and Process:

    • Use a For Each activity to loop through each match in ‘matches’.
    • Inside the loop, you can log or process each match.

There are some confusion still.

Get Outlook Mail Messages:

Use the “Get Outlook Mail Messages” activity to get emails and store them in the variable ‘mailsList’.
Find the Latest Email:

Use LINQ or other methods to find the latest email from ‘mailsList’.
How i can do it to get the latest?? which method or how??
Assign the latest email to a variable ‘latestEmail’.
Extract Email Content:

Assign latestEmailContent = latestEmail.Body
var type of latestEmailContent??
Apply Regular Expression:

Assign regexPattern = “(POD \d+|ABCDCOM \w+|Manually|Tayyab Imtiaz)”
var type of regexPattern??

Assign matches = System.Text.RegularExpressions.Regex.Matches(latestEmailContent, regexPattern)
var type of matches??
Loop through Matches and Process:

Use a For Each activity to loop through each match in ‘matches’.

Inside the loop, you can log or process each match.
??

On matches var i am getting the below error i have also change the var type to str or list but not works.

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