How to fetch attachments from the ".msg" mail file

How to fetch attachments from the ".msg" mail file ?

There are scenarios when user receives the mail  file in the form “.msg” format and wants to extract attachments from it . As of know there is no  activity which can accomplish this. 

To achieve this we either need to develop the custom activity or we can make use of  “.vbs” script  . Refer below steps to achieve it through ".vbs’ script:

1.)Create “.vbs” script  using below code:
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 “Path where you want to save the attachements” & Attch.FileName
End Sub

Refer below sample for specifying the path:
 Attch.SaveAsFile “D:\Attachements\Testing</b>” & Attch.FileName

2.)Then run the “.vbs” script  ,created from above step,  using the “Start Process” activity.

  • In the Arguments property of the aforementioned activity ,pass the ".msg" file path.
  • In the "FileName" property ,pass the full path of the ".vbs" script.

Using above approach,multiple attachments of different formats can also  be downloaded.