Extract from mail body

Hi everyone,

Can anyone share any ideas where I can extract few things from email. Meaning from the mail body.
The list that need to be extract from mail body are as below :
Subject
Received Date
Destination
Booking number
ETA
Identifier
Number of container and size

It would be really helpful if someone could help me out with this.

Regards,

1 Like

Hi @jnarthan.g

Mail subject & received date can be fetched using the function .subject & .DateAsDateTime, but in order to fetch the remaining details, can you please share a sample mail screen shot?

Best Regards.

hi @jnarthan.g

You can use Regular expression to extract the body of the mail,

Share a sample, we can help you out with it.

Hi @jnarthan.g, can you share a sample email body from which needs to be extracted the data, might help you with the regex,

Hi,

This is the sample body of needs to be extract from.

Could you help me with it ?

Regards,

Hi,

This is an sample of how they will send the email to RPA.
So I need to extract from here as you can see.

Regards,

1 Like

@jnarthan.g

I hope the subject format is destination booking numner and then eta

And body has multiple contaners and size if each container

If this is true then use

ETA = Mail.Subject.Split({"ETA"},Stringsplitoptions.None)(1).Trim

Hope id is 6 digits always

bookingId = Regex.Match(mail.Subject,"\d{6}").Value

Destination
dest = Regex.Match(mail.Subject,".*(?=\d{6})").Value

Container size and number
Mail.Body.Split({Environment.Newline},Stringsplitoptions.RemoveEmptyEntries) will split the body into multiple lines…you can use a loop to loop through each row as there are multipe rows of numberXsize

Inside the loop use

number = Regex.Match(currentitem,"\d+(?=X)").Value

size = Regex.Match(currentitem,"(?<=X)\d+)").Value

Cheers

2 Likes

Hi,

Can you send me this file as zip.
Would you send me that.
It would be more easier to learn from it.

Cheers

@jnarthan.g

You can just copy paste the same in your assign…are you having any difficulty when you copy these?

If for learning I wpuld suggest you to type the same so that you would remember as well

Cheers

Hi,

It’s cause I am that familiar which has to be where.
Can you do for me a sample and send me zip file of it please.

Cheers

@jnarthan.g

Will send it in a while…in the mean time…all the given expressions are to be in assign…the part before equals on left and after equals on right…before equals are the variables you need to create of string type

And the split for body as mentioned would f
Go to for loop

Cheers

Hi,.

Thank you so much ya. Really appreciated.
Will be waiting.
I will try to do it first.

Regards,

Hi,

If can send me asap ya.
I tried but kept getting error.
Not sure even I did it right.

Regards,

Hi,

Just to follow up.

Regards,

@jnarthan.g

Please check this

image

Open RegexMail.xaml
PepProcess - Copy (6).zip (7.4 KB)

cheers

1 Like

Hi,

A quick question. Do I have to create a separate module for this.

Regards,

Hi,

Bro I just tried it and realize that it’s hard coded. I would like your help with non hard coded rpa.

Regards,

Hi,

Its’s not suppose to hard coded. Meaning not manually type in it.

Should be automatically.

@jnarthan.g

I f you see the first two assigns I assigned two variables…either assign your subject and body to them or use mail.subject and mail.body in place of them…when i say mail.body mail is the variable containing your mail data

Cheers

Hi,

But it’s still manually key in right?
It’s not dynamic.
How to make it dynamic?

Regards,