I’m trying to identify how to extract the data out of this mail and store it as a variable.
I need to save “38” as variable “var_age”, “Prague” as “var_City” and so on.
The objective is to loop through all new mails with a certain subject, extract the values and write it in excel and then move the file from the inbox folder in Outlook to another folder.
You will get an out List say mailList, so you can use forEach mail in the mailList, do the below:
… a. Use Save Mail Message : pass mail, to: “temp.mht”
… b. Use Start Process, pass “temp.mht”. This will open the mail in the browser
… c. Use data scraping and scrape the table data into datatable
… d. Covert dt data into a list type using bodytableList =(From row In DataTableMail.Select() Select String.Join(“,”,row.ItemArray)).ToList() → you will get List[{“Age”, “38”},{“City”, “Prague”}…]
Now split to get each item: rowArray = bodytableList(0).Split(","c)
So, you get rowArray(0) = Age, rowArray(1)= 38 and so on…
Use activity Move Outlook Mail message, in: mail out, FolderName
Hi @nadim.warsi, thanks for your reply.
I think I’m doing something wrong at step 3.B. Can you have a look please?
When running it, i get the error “application can not be opened”.
Like @acaciomelo was saying, Start Process is to be used to open Applications, and .mht files are not applications. You can place “temp.mht” in the app arguments though, and put the application in the first field that will be opening the file (for example, the path to Internet Explorer or Outlook)
That indeed solved my problem. I don’t get the error anymore.
However my write line shows that the body of my mail is empty, however it is not empty in reality.
Hmmm. Can you try outputting the body of several emails in the Loop, ie outside of the If activity, so you can see everything?; maybe it’s showing a different email where the body was empty.
I tried but all the write lines for item.body.tostring are empty.
The item.subject.tostring is being treated correctly.
Can you have a look at the xaml please? It must be something easy like a parameter or a variable type that is wrong, but I can’t find it: mail test.xaml (7.3 KB)
(I just changed the account of the mailbox to not share it, but I’m using the correct account mailbox.)
It looks right to me.
You could try erasing .body and select it from the dropdown, shown in below image:
Although, that shouldn’t matter.
Only thing I can think of is that your messages don’t have a body. You should be able to tell that though by highlighting the text in the email to make sure it’s text-based. I think I would need an example of an email to look it over myself.
Another thing you can look at is the Headers which can contain other details of the message:
It’s a collection so I used String.Join to output all the items.
Thanks again for your reply. I tried your solutions (capital B for body) and joining the headers. But without result. Also, the mail is text based because when screen scraping, I do get the text.
However, when joining the headers I get a strange result as well in the output: “system.net.mime.Headercollection”.
Maybe the body problem and this have something related to each other?
Or is there another way to get the text out of the mails and storing it somewhere?
However, I am running out of ideas as well.
I found a lot of topics (also old ones) where people are having the same issue without solutions.
They can read the subject but not the body.
I also can’t use the activity “save mail attachments”.
I did not manage to solve it at that time. After running in circles for several months not finding a solution we decided not to automate this part. Also, we had another team at our company trying to automate such things and they did not manage either. For us, it seems to be an IT group policy thing that cannot be changed. It has something to do with a third party software not being allowed to use Outlook as far as I know.
This may be an old(ish) thread but don’t “open the mail in the browser” and then “use data scraping” from there - sub-optimal and waste of processing power.
Just imagine someone is implementing this suggestion (by a “Robot Master”?!) and uses it hundreds of times a day.
@MaurerDa It will be rather great if you provide a more optimal solution to a old thread if you feel there is one.
It will actually be helpful to the community readers reading this post