Read a .msg file and save attachement


I have an email file on the desktop (a .msg file extension). How do I read it and save the attachment like you can do with the Outlook method?.

'Outlook.MailItem' is not defined. Invoke code problem

This simple vbs should work fine, you could even pass the arguments in the Start Process activity.

Dim OlApp
Dim Eml
Dim Arg
Set Arg = WScript.Arguments
Dim File

File = Arg(0)

Set OlApp = CreateObject(“Outlook.Application”)
Set Eml = OlApp.CreateItemFromTemplate(File)

Sub Download(objEml)
For Each Attch In objEml.Attachments
Attch.SaveAsFile "C:\temp\" & Attch.FileName
End Sub

How to access the attachments from attachments objects that are .msg type of object and are emails themselves?
Retrieving attachments from saved email (.eml)
How to get attachments from mail messages already downloaded in folders
Call vbs in UIpath
"how to read mail message(.msg Files) saved in an folder"
Sending mail through .eml file in Outlook email
Read .msg file
How to read mail messages saved in a folder in explorer (a .msg file) as uipath mail objects

This worked. Thank you! I’m not very experienced with Visual Basic or C# so this was great.


Sorry I’m not familiar with Visual Basics. What if your file name has a lot of spaces. For example, examine this file.msg



Sorry for being a bit of an idiot but what is Dim? I’m completely stumped and any help would be greatly appreciated



This answer from web may help you understand DIM

Dim originally (in BASIC) stood for Dimension, as it was used to define the dimensions of an array.

(The original implementation of BASIC was Dartmouth BASIC, which descended from FORTRAN, where DIMENSION is spelled out.)

Nowadays, Dim is used to define any variable, not just arrays, so its meaning is not intuitive anymore.


i am getting vbscript compilation error. is there some settings to be enabled.


I am trying to see if there is any possibility to get the ‘Eml’ object in UI Path. Please can you help?


I remember reading somewhere about DIM as short for Declare In Memory? Was that wrong?


Hello, Can You please make yourself more clear. i do not understand, this since I am a beginner at uipath.
Thanks a lot much appreciated.


Hi vvaidya,

Is there a way to check for saved .msg file for certain content like “Approved” ?

Many Thanks,

closed #13