.msg file data extraction

Hey guys
I need a help on above topic
We have downloaded .msg file attachments from outloook
and we have to extract particular data from that .msg attachment
Attachments having access link which opening different types and need to extract it
Either by vb code or or html or anything useful
So any i solution, idea , suggestions will help me out
Thanks in advance


I hope this helps



Hi @Amar_Bhanvase

To extract particular data from a .msg attachment in UiPath, you can use the Outlook activities provided by UiPath. Here are the steps you can follow:

  1. Use the “Get Outlook Mail Messages” activity to retrieve the emails containing the .msg attachments.
  2. Loop through the emails using a “For Each” activity.
  3. Use the “Save Attachments” activity to save the .msg attachment to a local folder.
  4. Use the “Invoke Code” activity to write a custom VB code to extract the desired data from the .msg file.
  5. Use the extracted data as needed in your workflow.
1 Like

Hi @Amar_Bhanvase ,

Check this below link to read the .msg file and extract the details,

Hope this helps you :slight_smile:


Thanks for the same
I tried it but while making dynamic or passing argument it will give empty output

Thanks Nitya
We already developed rest of workflow
As you mentioned 4th step ,
I’m same expecting vb code which will extract data from .msg file
The data we want to extract is hyperlink or access link

Thanks Manish

But I already developed workflow upto downloaded outlook attachments as .msg file

After that need a help on extract data from that .msg attachments

And attachments having access link or hyperlink and that need to extract and process

So need a vb script forward code for extract same

Hi @Amar_Bhanvase

Here is the code-

Create an instance of the Outlook Application object

Set objOutlook = CreateObject(“Outlook.Application”)

Ask the user to select a .msg file

strFile = InputBox(“Enter the full path and filename of the .msg file to process:”)

Open the .msg file as a MailItem object
Set objMailItem = objOutlook.Session.OpenSharedItem(strFile)

Loop through the attachments of the MailItem object

For Each objAttachment In objMailItem.Attachments
’ Check if the attachment is a .txt file
If Right(objAttachment.FileName, 4) = “.txt” Then
Extract the text from the .txt file attachment
strText = objAttachment.Text
Process the text as needed

ElseIf Right(objAttachment.FileName, 4) = ".htm" Then

Extract the HTML from the .htm file attachment
strHTML = objAttachment.HTMLBody
Process the HTML as needed

ElseIf Right(objAttachment.FileName, 4) = ".url" Then

Extract the URL from the .url file attachment
Set objFSO = CreateObject(“Scripting.FileSystemObject”)
Set objFile = objFSO.OpenTextFile(objAttachment.Path)
strURL = objFile.ReadLine
Process the URL as needed

End If


Clean up
Set objFile = Nothing
Set objFSO = Nothing
Set objAttachment = Nothing
Set objMailItem = Nothing
Set objOutlook = Nothing

1 Like

Really thanks Nitya
I give a try and let you know if any isuue comes out

1 Like

This will help you to get files from .msg file in UiPath