SpecWorks.Message 0.5.0

dotnet add package SpecWorks.Message --version 0.5.0
                    
NuGet\Install-Package SpecWorks.Message -Version 0.5.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SpecWorks.Message" Version="0.5.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SpecWorks.Message" Version="0.5.0" />
                    
Directory.Packages.props
<PackageReference Include="SpecWorks.Message" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SpecWorks.Message --version 0.5.0
                    
#r "nuget: SpecWorks.Message, 0.5.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SpecWorks.Message@0.5.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SpecWorks.Message&version=0.5.0
                    
Install as a Cake Addin
#tool nuget:?package=SpecWorks.Message&version=0.5.0
                    
Install as a Cake Tool

Message.Net

A .NET library for parsing, validating, and serializing Internet message format (message/rfc822) data according to RFC 5322 and MIME (RFC 2045-2049).

Installation

dotnet add package Message.Net

Quick Start

Parsing a Message

using Message;

// Parse from string
var parser = new MessageParser();
var message = parser.Parse(emailText);

// Access headers
Console.WriteLine($"From: {message.From}");
Console.WriteLine($"To: {message.To}");
Console.WriteLine($"Subject: {message.Subject}");
Console.WriteLine($"Date: {message.Date}");

// Access body
if (message.IsMultipart)
{
    foreach (var part in message.Parts)
    {
        Console.WriteLine($"Part: {part.ContentType}");
    }
}
else
{
    Console.WriteLine($"Body: {message.TextBody}");
}

Validating a Message

var validator = new MessageValidator();
var result = validator.Validate(message);

if (result.IsValid)
{
    Console.WriteLine("Message is valid");
}
else
{
    foreach (var error in result.Errors)
    {
        Console.WriteLine($"Error: {error}");
    }
}

Creating a Message

var message = new MessageObject
{
    From = "sender@example.com",
    To = "recipient@example.com",
    Subject = "Hello World",
    Date = DateTimeOffset.Now
};
message.SetTextBody("This is the message body.");

var serializer = new MessageSerializer();
var output = serializer.Serialize(message);

Working with MIME

// Create a multipart message
var message = new MessageObject
{
    From = "sender@example.com",
    To = "recipient@example.com",
    Subject = "Message with attachment"
};

// Add text part
message.AddPart(new MimePart
{
    ContentType = "text/plain",
    Content = "This is the plain text body"
});

// Add HTML part
message.AddPart(new MimePart
{
    ContentType = "text/html",
    Content = "<html><body><h1>Hello</h1></body></html>"
});

// Add attachment
message.AddAttachment("document.pdf", pdfBytes, "application/pdf");

Features

  • Full RFC 5322 Support - Headers, folding, structured fields
  • MIME Support - Multipart messages, encodings, attachments
  • Content-Transfer-Encoding - Base64, Quoted-Printable, 7bit, 8bit
  • Encoded Words (RFC 2047) - Non-ASCII text in headers
  • Validation - Comprehensive validation against specifications
  • Streaming - Parse and serialize large messages efficiently

API Reference

MessageParser

  • Parse(string text) - Parse message from string
  • ParseFile(string path) - Parse message from file
  • ParseStream(Stream stream) - Parse message from stream

MessageValidator

  • Validate(MessageObject message) - Validate message structure

MessageSerializer

  • Serialize(MessageObject message) - Serialize to string
  • SerializeToStream(MessageObject message, Stream stream) - Serialize to stream

Specifications

  • RFC 5322 - Internet Message Format
  • RFC 2045 - MIME Part One: Format of Internet Message Bodies
  • RFC 2046 - MIME Part Two: Media Types
  • RFC 2047 - MIME Part Three: Message Header Extensions for Non-ASCII Text

License

MIT License

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

    • No dependencies.
  • net10.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.5.0 107 1/27/2026

Initial release with full RFC 5322 and MIME support.