I want to extract each document details from this email body

Email is like this:

"
Dear user,

The following documents were updated:

Document number: 3455565
Publication Date: 6/30/2022
Title: Auto
Status: Active
Type of Change: Complete Revision
Document number: 56566
Publication Date: 5/31/2022
Title: Test
Status: Active
Type of Change: Complete Revision

You have received this email because you were added to the list of users to be notified about updates in "

I want Data like each document details in an array

Hi!

What do you mean by document details?

Regards,
NaNi

First doc details

Document number: 3455565
Publication Date: 6/30/2022
Title: Auto
Status: Active
Type of Change: Complete Revision

Second Doc details

Document number: 56566
Publication Date: 5/31/2022
Title: Test
Status: Active
Type of Change: Complete Revision

Hey!

Array is fixed size you can’t add the items to it…

But you can add the data to list.

You can achieve this by creating a list of string variable and take one add to collection item you can achieve this…

Follow the below regex to extract the data:

Get the mails using IMAP Output as → Mail message

Take one for each pass the ->Mail message

Inside the For each do like this

DocumentNumber:

Assign DocumentNumber = System.Text.RegularExpressions.Regex.match(item,"(?<=Document number: ).*").ToString

PublicationDate:

Assign PublicationDate = System.Text.RegularExpressions.Regex.match(item,"(?<=Publication Date: ).*").ToString

Title:

Assign Title = System.Text.RegularExpressions.Regex.match(item,"(?<=Title: ).*").ToString

Status:

Assign Status = System.Text.RegularExpressions.Regex.match(item,"(?<=Status: ).*").ToString

Type of change:

Assign Type_of_change = System.Text.RegularExpressions.Regex.match(item,"(?<=Type of Change: ).*").ToString

Try this and let me know

Regards,
NaNi

1 Like

All the document details will be in one email. I need each document detail has a block
First document and related details and follows for other documents

Hi @Zara_Yasmin ,

If the format of the Document details are the same always, then we could try the below Regex Expression :

Document number:\s(\d+)\nPublication Date:\s(\d{1,2}\/\d{1,2}\/\d{1,4})\nTitle:\s(.*)\nStatus:\s(.*)\nType of Change:(.*)

We could use the above regex expression in Matches Activity to get the matches and capture the required data using Groups accordingly.

Let us know if you need more details.

1 Like

Thank you very much… This worked

1 Like

After extracting the block… Am able to extract individual items like you explained. Thank you for your time !!

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