To get the selected data only from email and write it into excel

I want to extract data from email, below is the body part of email which is a template we get, we want to get data in table form, columns like date, from, subject, Leave type, Fromdate, Todate, Days, Reason. we want The leave request details(seems like table), but not able to get this table using data scraping. I am able to get the column like date, from, subject, Using build data table and add data row,
Problem1- How to get the data from “Leave Request details”
Problem2- How to get the data only from the reason part.
Below is the EmailBody-
Hi there,

Leave request from date: 07-07-2022 to 08-07-2022


Dear Sir, I want to go to (Varanasi) with my family on a three days trip. Therefore, I need three days’ leave (7th ,8th & 11th of July ) from the office to enjoy this tour. I will be grateful for your kind approval.

Leave Request Details

Leave Type From Date To Date Days
Earned/Privilege leave-EL 07-07-2022 08-07-2022 2

Leave Availability

Leave type Availability
Paid Leave 6
Sick Leave -1.5

AKhil Singhal

Hi akhils,

Once you have the email into a mail message variable you can use the .body function.

To get the Leave Request Details:

str_LeaveRequestDetails = Split(mm_Body,“Leave Request Details”)(1)
str_LeaveRequestDetails = Split(str_LeaveRequstDetails,“Leave Availability”)(0)

To get the Leave Reason:

str_LeaveReason = Split(mm_Body,“Reason:”)(1).Trim
str_LeaveReason = Split(str_LeaveRequstDetails,“Leave Request Details”)(0)

Hope this helps,


Thankyou so much. I implemented the same and successfully completed.

Hi akhils,

Brilliant. Glad it worked for you.

Could you please mark my original comment as the solution to close the topic and help people in the future.


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