{"id":4371,"date":"2013-10-14T20:59:13","date_gmt":"2013-10-14T18:59:13","guid":{"rendered":"http:\/\/www.limilabs.com\/blog\/?p=4371"},"modified":"2014-08-16T12:09:57","modified_gmt":"2014-08-16T10:09:57","slug":"convert-outlook-msg-file-to-mime-format-in-net","status":"publish","type":"post","link":"https:\/\/www.limilabs.com\/blog\/convert-outlook-msg-file-to-mime-format-in-net","title":{"rendered":"Convert Outlook .msg file to MIME 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><a href=\"\/blog\/reading-outlook-msg-file-format-net\">Reading Outlook .msg file format in .NET<\/a><\/li>\n<li>Convert Outlook .msg file to MIME format in .NET<\/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 convert .msg files to MIME, 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 saves it using MIME format to disk. MIME is shorthand for Multipurpose Internet Mail Extensions and is an Internet standard used to store and transport email messages.<\/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        \/\/ Render message using MIME format to byte array\r\n        byte&#x5B;] mime = email.Render();\r\n\r\n        \/\/ Save message to file using MIME message format\r\n        email.Save(@&quot;c:\\mime.eml&quot;);\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\nIf converter.Type = MsgType.Note Then\r\n    Dim email As IMail = converter.CreateMessage()\r\n\r\n\t' Render message using MIME format to byte array\r\n\tDim mime As Byte() = email.Render()\r\n\r\n\t' Save message to file using MIME message format\r\n\temail.Save(&quot;c:\\mime.eml&quot;)\r\n    End If\r\nEnd Using\r\n<\/pre>\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,21,34,100,99],"class_list":["post-4371","post","type-post","status-publish","format-standard","hentry","category-mail-dll","tag-email-component","tag-exchange","tag-mime","tag-msg","tag-outlook"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/4371"}],"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=4371"}],"version-history":[{"count":11,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/4371\/revisions"}],"predecessor-version":[{"id":4772,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/4371\/revisions\/4772"}],"wp:attachment":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/media?parent=4371"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/categories?post=4371"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/tags?post=4371"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}