
We can get Text and Rtf body of the message by using properties of MapiMessage class. Getting the Text Body and Rtf Body of the Message subjectif (msg.Subject != null)Console.WriteLine(msg.Subject) elseConsole.WriteLine("no subject") // senderif (msg.SenderEmailAddress != null)Console.WriteLine(msg.SenderEmailAddress) elseConsole.WriteLine("No sender") // toif (msg.DisplayTo != null)Console.WriteLine(msg.DisplayTo) elseConsole.WriteLine("No one in To") // ccif (msg.Displa圜c != null)Console.WriteLine(msg.Displa圜c) elseConsole.WriteLine("No one in cc") ' subjectIf Not msg.Subject Is Nothing ThenConsole.WriteLine(msg.Subject)ElseConsole.WriteLine("no subject")End If' senderIf Not msg.SenderEmailAddress Is Nothing ThenConsole.WriteLine(msg.SenderEmailAddress)ElseConsole.WriteLine("No sender")End If' toIf Not msg.DisplayTo Is Nothing ThenConsole.WriteLine(msg.DisplayTo)ElseConsole.WriteLine("No one in To")End If' ccIf Not msg.Displa圜c Is Nothing ThenConsole.WriteLine(msg.Displa圜c)ElseConsole.WriteLine("No one in cc")End If
#EMAIL PARSER OUTLOOK CODE#
Following is the sample code for getting these properties. MapiMessage class exposes properties and collections for getting subject, to, cc and from.


MapiMessage msg = MapiMessage.FromFile(“C:\\SomeFolder\\SomeMsgFile.msg”) Dim msg As MapiMessage = MapiMessage.FromFile(“C:\\SomeFolder\\SomeMsgFile.msg”) Getting the From, To, Cc and Subject from Msg File You can load the msg file using a single line of code by calling FromFile() static method and passing the path of the msg file. In this section, we will present the code that we used in the demo to show the msg file contents.Īspose.Network library provides MapiMessage class for loading and parsing msg files.
#EMAIL PARSER OUTLOOK HOW TO#
How to Parse and View Msg File contents Programmatically

A separate Outlook msg Viewer Demo (attached with this article) is also available to guide you for parsing and reading Outlook. msg files using your own code in C# applications where Microsoft Office Outlook is not required for it. This article shows that how can you parse and view Outlook.
