{"id":4370,"date":"2013-10-14T20:44:18","date_gmt":"2013-10-14T18:44:18","guid":{"rendered":"http:\/\/www.limilabs.com\/blog\/?p=4370"},"modified":"2014-04-09T15:09:39","modified_gmt":"2014-04-09T13:09:39","slug":"reading-outlook-msg-file-format-net","status":"publish","type":"post","link":"https:\/\/www.limilabs.com\/blog\/reading-outlook-msg-file-format-net","title":{"rendered":"Reading Outlook .msg file format in .NET"},"content":{"rendered":"<p>Files containing the .msg file extension are most commonly created by or saved from within one of the Microsoft Outlook email applications. <\/p>\n<div class=\"well\">\n<ul>\n<li>Reading Outlook .msg file format in .NET<\/li>\n<li><a href=\"\/blog\/convert-outlook-msg-file-to-mime-format-in-net\">Convert Outlook .msg file to MIME format in .NET<\/a><\/li>\n<\/ul>\n<\/div>\n<p>The MSG file contains information about a saved email file including the date of the message, the subject, who sent it, who received it and the contents of the email associated with the file. If attachments ares included with an email, that information will also be saved within the associated MSG file.<\/p>\n<p><em>MsgConverter <\/em>, than can be used to read .msg files, is written in pure .NET, it does not require registration or any other components or libraries (including Outlook).<\/p>\n<p>The following code snippet reads .msg file in .NET and access its most common properties, such as subject, sender and attachments.<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\/\/ C#\r\n\r\nusing (MsgConverter converter = new MsgConverter(@&quot;c:\\outlook1.msg&quot;))\r\n{\r\n    if (converter.Type == MsgType.Note)\r\n    {\r\n        IMail email = converter.CreateMessage();\r\n\r\n        Console.WriteLine(&quot;Subject: {0}&quot;, email.Subject);\r\n        Console.WriteLine(&quot;Sender name: {0}&quot;, email.Sender.Name);\r\n        Console.WriteLine(&quot;Sender address: {0}&quot;, email.Sender.Address);\r\n\r\n        Console.WriteLine(&quot;Attachments: {0}&quot;, email.Attachments.Count);\r\n        foreach (MimeData attachment in email.Attachments)\r\n        {\r\n            attachment.Save(@&quot;c:\\&quot; + attachment.SafeFileName);\r\n        }\r\n    }\r\n}\r\n<\/pre>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n' VB.NET\r\n\r\nUsing converter As New MsgConverter(&quot;c:\\outlook1.msg&quot;)\r\n    If converter.Type = MsgType.Note Then\r\n        Dim email As IMail = converter.CreateMessage()\r\n\r\n        Console.WriteLine(&quot;Subject: {0}&quot;, email.Subject)\r\n        Console.WriteLine(&quot;Sender name: {0}&quot;, email.Sender.Name)\r\n        Console.WriteLine(&quot;Sender address: {0}&quot;, email.Sender.Address)\r\n        \r\n        Console.WriteLine(&quot;Attachments: {0}&quot;, email.Attachments.Count)\r\n        For Each attachment As MimeData In email.Attachments\r\n            attachment.Save(&quot;c:\\&quot; + attachment.SafeFileName)\r\n        Next\r\n\r\n    End If\r\nEnd Using\r\n<\/pre>\n<p>You can read more on <a href=\"\/blog\/how-to-access-to-cc-bcc-fields\">how to access To, Cc, Bcc fields<\/a>. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Files containing the .msg file extension are most commonly created by or saved from within one of the Microsoft Outlook email applications. Reading Outlook .msg file format in .NET Convert Outlook .msg file to MIME format in .NET The MSG file contains information about a saved email file including the date of the message, the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[33,20,21,34,100,99],"class_list":["post-4370","post","type-post","status-publish","format-standard","hentry","category-mail-dll","tag-email-component","tag-eml","tag-exchange","tag-mime","tag-msg","tag-outlook"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/4370"}],"collection":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/comments?post=4370"}],"version-history":[{"count":12,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/4370\/revisions"}],"predecessor-version":[{"id":4512,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/4370\/revisions\/4512"}],"wp:attachment":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/media?parent=4370"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/categories?post=4370"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/tags?post=4370"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}