I believe that the only way to read an Outlook .msg file (in order to extra metadata like subject, attachments etc), is to use the Outlook API - the Application.Session.OpenSharedItem()
method.
If this is the case, then I am looking for way to run this code on our application server, which doesn't have MS OFfice or MS Outlook installed. I'm getting the error
System.ArgumentException: progId not found. Outlook.Application
Which of course is due to the absence of the Outlook application.
Is there any way to install just a DLL or something in order to get the OpenSharedItem method to work? I don't want to have to install the full client if possible.
Or, is there a way to parse a .msg file without requiring significant dependencies such as Outlook?
You can also
explicitly parse the MSG file (its format is documented).
Use Extended MAPI (C++ or Delphi only) along with the standalone version of MAPI. Look up OpenIMsgOnIStg function on MSDN.
Use Redemption (requires a MAPI system - Outlook or the standalone version of MAPI must be installed - and its RDOSession.
GetMessageFromMsgFile
method:MSG .NET is Microsoft Outlook .msg file API for .NET Framework. The API allows you to easy create/read/parse/convert .msg files and more. The API does not require Microsoft Outlook to be installed on the machine or any other third party application or library in order to work.
Here is the solution to read the attachement in an msg file
following library is used
This was answered in a codeplex article I have saved from a long time ago
Article is here, there is a file called OutlookStorage.cs that does not require the outlook model.
As in the comments below there is now a nuget package that covers this:
here
Props to Simon Green in the comments for this.