{"id":21471948,"url":"https://github.com/sicos1977/msgreader","last_synced_at":"2025-04-13T18:37:50.153Z","repository":{"id":14167376,"uuid":"16873398","full_name":"Sicos1977/MSGReader","owner":"Sicos1977","description":"C# Outlook MSG file reader without the need for Outlook","archived":false,"fork":false,"pushed_at":"2024-05-22T10:57:38.000Z","size":24867,"stargazers_count":464,"open_issues_count":4,"forks_count":166,"subscribers_count":36,"default_branch":"master","last_synced_at":"2024-05-22T11:28:41.978Z","etag":null,"topics":["email","email-parsing","eml","msg","outlook"],"latest_commit_sha":null,"homepage":"http://sicos1977.github.io/MSGReader","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Sicos1977.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"license.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["Sicos1977"]}},"created_at":"2014-02-15T22:35:17.000Z","updated_at":"2024-05-29T20:25:19.885Z","dependencies_parsed_at":"2023-01-13T17:49:35.079Z","dependency_job_id":"6a9e280a-c027-4355-aece-5924fed91376","html_url":"https://github.com/Sicos1977/MSGReader","commit_stats":{"total_commits":1002,"total_committers":43,"mean_commits":"23.302325581395348","dds":0.5658682634730539,"last_synced_commit":"42d76a5f8140cc098f1d0be254723e5852db2351"},"previous_names":[],"tags_count":131,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sicos1977%2FMSGReader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sicos1977%2FMSGReader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sicos1977%2FMSGReader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sicos1977%2FMSGReader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sicos1977","download_url":"https://codeload.github.com/Sicos1977/MSGReader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248762443,"owners_count":21157735,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["email","email-parsing","eml","msg","outlook"],"created_at":"2024-11-23T09:46:42.913Z","updated_at":"2025-04-13T18:37:50.128Z","avatar_url":"https://github.com/Sicos1977.png","language":"C#","funding_links":["https://github.com/sponsors/Sicos1977"],"categories":[],"sub_categories":[],"readme":"What is MSGReader\n=========\n\nMSGReader is a C# .NET 4.6.2, .NET Standard 2.0 and .NET Standard 2.1 assembly to read Outlook MSG and EML (Mime 1.0) files. Almost all common object in Outlook are supported:\n\n- E-mail\n- Appointment\n- Task\n- Contact card\n- Sticky note\n\nIt supports all body types there are in MSG files, this includes:\n\n- Text\n- HTML\n- HTML embedded into RTF\n- RTF\n\nMSGReader has only a few options to manipulate an MSG file. The only option you have is that you can remove attachments and then save the file to a new one.\n\nIf you realy want to write MSG files then see my MsgKit project on GitHub (https://github.com/Sicos1977/MsgKit)\n\nRead properties from an Outlook (msg) message\n============\n```c#\nusing (var msg = new MsgReader.Outlook.Storage.Message(\"d:\\\\testfile.msg\"))\n{\n        var from = msg.Sender;\n        var sentOn = msg.SentOn;\n        var recipientsTo = msg.GetEmailRecipients(MsgReader.Outlook.RecipientType.To, false, false);\n        var recipientsCc = msg.GetEmailRecipients(MsgReader.Outlook.RecipientType.Cc, false, false);\n        var subject = msg.Subject;\n        var htmlBody = msg.BodyHtml;\n        // etc...\n}\n```\n\nDetecting charset encoding in MSG files with HTML encapuslated into RTF that use different font set encodings\n============\n\nMost of the times when an HTML body is used in an MSG file this HTML body is encapsulated into RTF.\nSee this link for more info --\u003e https://learn.microsoft.com/en-us/openspecs/exchange_server_protocols/ms-oxrtfex/4f09a809-9910-43f3-a67c-3506b09ca5ac\n\nWhen an HTML body contains chars that are not in the default extended ASCII range then these chars are encoded. This is normally not a problem when just one language is used.\nWhen multiple languages are used then it is quite often that the RTF is not build correctly in a way so that MSGReader can figure out what kind of encoding needs to be used to decode the chars. Because of this MSGReader uses the nuget package UTF.Unknown (https://www.nuget.org/packages/UTF.Unknown/) to try to figure out in what kind of encoding a char is stored. Most of the times this works correctly and because of that a threshold is set to a value of 0.90 so that when the detection level passes this value it will be seen as a valid char.\n\nIf you still have bad results you can control this confidence level yourself by using the property `CharsetDetectionEncodingConfidenceLevel` in the `Reader` or `Message` class\n\n\n```c#\n/// \u003csummary\u003e\n///     When an MSG file contains an RTF file with encapsulated HTML and the RTF\n///     uses fonts with different encodings then this levels set the threshold that\n///     an encoded string detection levels needs to be before recognizing it as a valid\n///     string. When the detection level is lower than this setting then the default RTF\n///     encoding is used to decode the encoded char \n/// \u003c/summary\u003e\n/// \u003cremarks\u003e\n///     Default this value is set to 0.90, any values lower then 0.70 probably give bad\n///     results\n/// \u003c/remarks\u003e\npublic float CharsetDetectionEncodingConfidenceLevel { get; set; } = 0.90f;\n```\n\n\n\nRead properties from an Outlook (eml) message\n============\n```c#\nvar fileInfo = new FileInfo(\"d:\\\\testfile.eml\");\nvar eml = MsgReader.Mime.Message.Load(fileInfo);\n\nif (eml.Headers != null)\n{\n        if (eml.Headers.To != null)\n        {\n            foreach (var recipient in eml.Headers.To)\n            {\n                var to = recipient.Address;            \n            }\n        }\n}\n\nvar subject = eml.Headers.Subject;\n\nif (eml.TextBody != null)\n{\n        var textBody = System.Text.Encoding.UTF8.GetString(eml.TextBody.Body);\n}\n\nif (eml.HtmlBody != null)\n{\n        var htmlBody = System.Text.Encoding.UTF8.GetString(eml.HtmlBody.Body);\n}\n\n// etc...\n```\n\nDelete attachment from an Outlook message\n============\n\nThis example deletes the first attachment\n\n```c#\nvar outlook = new Storage.Message(fileName, FileAccess.ReadWrite);\noutlook.DeleteAttachment(outlook.Attachments[0]);\noutlook.Save(\"d:\\\\deleted.msg\");\n```\n\nTranslations\n============\n\n- Kees van Spelde\n    - English (US)\n    - Dutch\n\n- Ronald Kohl\n    - German\n\n- Yan Grenier (@ygrenier on GitHub)\n    - French\n\n- xupefei\n    - Simpl Chinese\n\nInstalling via NuGet\n====================\n\n[![NuGet](https://img.shields.io/nuget/v/MSGReader.svg?style=flat-square)](https://www.nuget.org/packages/MSGReader)\n\nThe easiest way to install MSGReader is via NuGet.\n\nIn Visual Studio's Package Manager Console, simply enter the following command:\n\n    Install-Package MSGReader\n\n\nSide note\n=========\n\nThis project can also be used from a COM based language like VB script or VB6.\nTo use it first compile the code and register the com visible assembly with the command:\n\nRegasm.exe /codebase MsgReader.dll\n\nAfter that you can call it like this:\n\n```vb\ndim msgreader\n\nset msgreader = createobject(\"MsgReader.Reader\")\nmsgreader.ExtractToFolderFromCom \"the msg file to read\", \"the folder where to place the extracted files\"\n```\n\n## License Information\n\nMsgReader is Copyright (C) 2013-2025 Magic-Sessions and is licensed under the MIT license:\n\n    Permission is hereby granted, free of charge, to any person obtaining a copy\n    of this software and associated documentation files (the \"Software\"), to deal\n    in the Software without restriction, including without limitation the rights\n    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n    copies of the Software, and to permit persons to whom the Software is\n    furnished to do so, subject to the following conditions:\n\n    The above copyright notice and this permission notice shall be included in\n    all copies or substantial portions of the Software.\n\n    THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n    FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE\n    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n    THE SOFTWARE.\n\nCore Team\n=========\n    Sicos1977 (Kees van Spelde)\n\nSupport\n=======\nIf you like my work then please consider a donation as a thank you by using the donate button at the top\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsicos1977%2Fmsgreader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsicos1977%2Fmsgreader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsicos1977%2Fmsgreader/lists"}