How to Filter Email Fields?

I have one doubt, I have a variable and value which is scraped from Email. Now I need a way to filter and take few required fields. Please find below the variable’s value.

[

{
“from”: [
{
“address”: “MailID”,
“name”: “Name”
}
],
“date”: “2022-11-09T06:26:38.000Z”,
“receivedDate”: “2022-11-09T06:26:40.000Z”,
“to”: [
{
“address”: “EmailID”,
“name”: “Name”
}
],
“subject”: “Today’s Palm oil prices (Assuming prices are in a table)”,
“text”: “\n\n\nHi,\n\n\n\n\n\n\n\nPlease update the prices as below to respective clients.\n\n\n\n\n\n\n\nBurger Kings - oil prices\n\n\n\n\n\n\n\nSl. no. Item Price per MT (in Indonesian Rupiah) \n1 Raw oil 15738000 \n2 Refined Oil 17583000 \n\n\n\n\n\n\n\nKFC - oil prices\n\n\n\n\n\n\n\nSl. no. Item Price per MT (in Indonesian Rupiah) \n1 Raw oil 15738000 \n2 Refined Oil 17583000 \n\n\n\n\n\n\n\nMcDonald’s - oil prices\n\n\n\n\n\n\n\nSl. no. Item Price per MT (in Indonesian Rupiah) \n1 Raw oil 15738000 \n2 Refined Oil 17583000 \n\n\n\n\n\n\n\nRegards,\n\n\nJeevan updates\nContact: xxxxxxx”,
“textPlain”: “Hi,\n\nPlease update the prices as below to respective clients.\n\nBurger Kings - oil prices\n\nSl. no. Item Price per MT (in Indonesian Rupiah)\n1 Raw oil 15738000\n2 Refined Oil 17583000\n\nKFC - oil prices\n\nSl. no. Item Price per MT (in Indonesian Rupiah)\n1 Raw oil 15738000\n2 Refined Oil 17583000\n\nMcDonald’s - Palm oil prices\n\nSl. no. Item Price per MT (in Indonesian Rupiah)\n1 Raw oil 15738000\n2 Refined Oil 17583000\n\nRegards,\nJeevan updates\nContact: xxxxxxx\n”,
“hasAttachment”: false,
“cc”: [
{
“address”: “MailId”,
“name”: “Name”
}
],
“attachments”:
}
]

From this variable’s value, I need to filter all those bolded fields. please help me out how to filter only these results/fields. Thanks

Hi @Rudhresh,

It is a interesting task, let me try to help you.
As I can see, the values that you need to extract are repeated in lines of “text” and “textPlain”, so lets use this second one for this example.

What you will need to do is to create a new variable (which means a new Assign value to variable activity), and for the value of this variable we are going to use the “Calculate value” option and the content will be email_messages[0][“textPlain”], like this:

image

I am assuming that the variable you received the data of your email is called “email_messages”.

So this new variable “string_data” will have in one string all the information you want to extract, now you can use the “extract text” activity to get all the pieces you need.

In this article you will find more details of how to work with the Extract text activity:

I hope it helps! Let me know if it works for you

2 Likes