MsgReader 4.5.1
See the version list below for details.
dotnet add package MsgReader --version 4.5.1
NuGet\Install-Package MsgReader -Version 4.5.1
<PackageReference Include="MsgReader" Version="4.5.1" />
paket add MsgReader --version 4.5.1
#r "nuget: MsgReader, 4.5.1"
// Install MsgReader as a Cake Addin #addin nuget:?package=MsgReader&version=4.5.1 // Install MsgReader as a Cake Tool #tool nuget:?package=MsgReader&version=4.5.1
What is MSGReader
MSGReader is a C# .NET 4.6.2, NET Standard 2.0 and NET 5.0 library to read Outlook MSG and EML (Mime 1.0) files. Almost all common object in Outlook are supported:
- Appointment
- Task
- Contact card
- Sticky note
It supports all body types there are in MSG files, this includes:
- Text
- HTML
- HTML embedded into RTF
- RTF
MSGReader 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.
If you realy want to write MSG files then see my MsgKit project on GitHub (https://github.com/Sicos1977/MsgKit)
Read properties from an Outlook (msg) message
using (var msg = new MsgReader.Outlook.Storage.Message("d:\\testfile.msg"))
{
var from = msg.Sender;
var sentOn = msg.SentOn;
var recipientsTo = msg.GetEmailRecipients(MsgReader.Outlook.RecipientType.To, false, false);
var recipientsCc = msg.GetEmailRecipients(MsgReader.Outlook.RecipientType.Cc, false, false);
var subject = msg.Subject;
var htmlBody = msg.BodyHtml;
// etc...
}
Read properties from an Outlook (eml) message
var fileInfo = new FileInfo("d:\\testfile.eml");
var eml = MsgReader.Mime.Message.Load(fileInfo);
if (eml.Headers != null)
{
if (eml.Headers.To != null)
{
foreach (var recipient in eml.Headers.To)
{
var to = recipient.Address;
}
}
}
var subject = eml.Headers.Subject;
if (eml.TextBody != null)
{
var textBody = System.Text.Encoding.UTF8.GetString(eml.TextBody.Body);
}
if (eml.HtmlBody != null)
{
var htmlBody = System.Text.Encoding.UTF8.GetString(eml.HtmlBody.Body);
}
// etc...
Delete attachment from an Outlook message
This example deletes the first attachment
var outlook = new Storage.Message(fileName, FileAccess.ReadWrite);
outlook.DeleteAttachment(outlook.Attachments[0]);
outlook.Save("d:\\deleted.msg");
Translations
Kees van Spelde
- English (US)
- Dutch
Ronald Kohl
- German
Yan Grenier (@ygrenier on GitHub)
- French
xupefei
- Simpl Chinese
Installing via NuGet
The easiest way to install MSGReader is via NuGet.
In Visual Studio's Package Manager Console, simply enter the following command:
Install-Package MSGReader
Side note
This project can also be used from a COM based language like VB script or VB6. To use it first compile the code and register the com visible assembly with the command:
Regasm.exe /codebase MsgReader.dll
After that you can call it like this:
dim msgreader
set msgreader = createobject("MsgReader.Reader")
msgreader.ExtractToFolderFromCom "the msg file to read", "the folder where to place the extracted files"
License Information
MsgReader is Copyright (C) 2013-2023 Magic-Sessions and is licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Core Team
Sicos1977 (Kees van Spelde)
Support
If you like my work then please consider a donation as a thank you.
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=NS92EXB2RDPYA" target="_blank"><img src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" /></a>
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- Microsoft.IO.RecyclableMemoryStream (>= 2.3.2)
- Microsoft.Maui.Graphics (>= 7.0.59)
- NETStandard.Library (>= 2.0.3)
- OpenMcdf (>= 2.2.1.12)
- RtfPipe (>= 2.0.7677.4303)
-
.NETStandard 2.0
- Microsoft.IO.RecyclableMemoryStream (>= 2.3.2)
- Microsoft.Maui.Graphics (>= 7.0.59)
- NETStandard.Library (>= 2.0.3)
- OpenMcdf (>= 2.2.1.12)
- RtfPipe (>= 2.0.7677.4303)
- System.Security.Cryptography.Pkcs (>= 4.5.1)
-
.NETStandard 2.1
- Microsoft.IO.RecyclableMemoryStream (>= 2.3.2)
- Microsoft.Maui.Graphics (>= 7.0.59)
- NETStandard.Library (>= 2.0.3)
- OpenMcdf (>= 2.2.1.12)
- RtfPipe (>= 2.0.7677.4303)
- System.Security.Cryptography.Pkcs (>= 4.5.1)
-
net5.0
- Microsoft.IO.RecyclableMemoryStream (>= 2.3.2)
- Microsoft.Maui.Graphics (>= 7.0.59)
- NETStandard.Library (>= 2.0.3)
- OpenMcdf (>= 2.2.1.12)
- RtfPipe (>= 2.0.7677.4303)
- System.Security.Cryptography.Pkcs (>= 7.0.1)
-
net6.0
- Microsoft.IO.RecyclableMemoryStream (>= 2.3.2)
- Microsoft.Maui.Graphics (>= 7.0.59)
- NETStandard.Library (>= 2.0.3)
- OpenMcdf (>= 2.2.1.12)
- RtfPipe (>= 2.0.7677.4303)
- System.Security.Cryptography.Pkcs (>= 7.0.1)
NuGet packages (9)
Showing the top 5 NuGet packages that depend on MsgReader:
Package | Downloads |
---|---|
SuperOffice.NetServer.Core
SuperOffice NetServer Core is SuperOffice's data access technology for new applications. This is for onsite installations with the same version. This also works with SuperOffice Online. |
|
Toxy
.NET text extraction framework |
|
invoisys.SDK.EML
Package Description |
|
PasswordProtectedChecker
Package Description |
|
OfficeExtractor
Extracts embedded OLE objects from Word, Excel, PowerPoint and Open Office files without needing the original programs. |
GitHub repositories (4)
Showing the top 4 popular GitHub repositories that depend on MsgReader:
Repository | Stars |
---|---|
QL-Win/QuickLook
Bring macOS “Quick Look” feature to Windows
|
|
bitfoundation/bitplatform
Build all of your apps using what you already know and love ❤️
|
|
nissl-lab/toxy
.net text extraction framework
|
|
EvotecIT/Mailozaurr
Mailozaurr is a PowerShell module that aims to provide SMTP, POP3, IMAP and probably some other ways to interact with Email. Underneath it uses MimeKit and MailKit libraries written by Jeffrey Stedfast.
|
Version | Downloads | Last updated |
---|---|---|
5.7.0 | 21,791 | 11/8/2024 |
- Added support for tnef winmail.dat attachments
- Upgraded nuget package
- Some other minor bug fixes
- Replaced SixLabors.ImageSharp with Maui because off license restrictions when using in a commerical app
- Fix issue with storage guid not beeing set anymore